我需要在Dialog顶部布置一个面板,使其有两个按钮(Save和Cancel).
我希望保存在左侧,取消在右侧.
我已经使用MigLayout创建了一个JPanel并将其停靠在内容窗格的北部,并且在我的生活中无法弄清楚如何将两个按钮添加到它以便它们按我想要的那样显示.将它们停靠在面板中似乎摆脱了对话框中的所有填充(看起来很糟糕).
任何帮助将不胜感激.
在浏览一些代码时,我遇到了这一行:
if False: #shedskin
Run Code Online (Sandbox Code Playgroud)
据我所知,Shedskin是一种Python - > C++编译器,但我无法理解这一行.
不应该if False:永远不执行?这里发生了什么?
对于上下文:
这是整个块:
if False: # shedskin
AStar(SQ_MapHandler([1], 1, 1)).findPath(SQ_Location(1,1), SQ_Location(1,1))
Run Code Online (Sandbox Code Playgroud)
Google Code上有更多背景信息(向下滚动).
我从字面上复制并粘贴了C的数字配方的源代码,用于就地LU矩阵分解,问题是它不起作用.
我确信我做的事情很愚蠢,但我很高兴有人能指出我正确的方向; 我整天都在努力工作,看不出我做错了什么.
POST-ANSWER UPDATE:项目已完成并正在运行.感谢大家的指导.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define MAT1 3
#define TINY 1e-20
int h_NR_LU_decomp(float *a, int *indx){
//Taken from Numerical Recipies for C
int i,imax,j,k;
float big,dum,sum,temp;
int n=MAT1;
float vv[MAT1];
int d=1.0;
//Loop over rows to get implicit scaling info
for (i=0;i<n;i++) {
big=0.0;
for (j=0;j<n;j++)
if ((temp=fabs(a[i*MAT1+j])) > big)
big=temp;
if (big == 0.0) return -1; //Singular Matrix
vv[i]=1.0/big;
}
//Outer kij loop
for (j=0;j<n;j++) {
for (i=0;i<j;i++) {
sum=a[i*MAT1+j];
for …Run Code Online (Sandbox Code Playgroud) 我有两个文档都很相似,但我需要找到一种优雅而有效的方法来比较这两个文件并返回Doc#1中Doc#2中不存在的值.
XML Doc#1
<ids>
<id>1</id>
<id>2</id>
<id>5</id>
<id>6</id>
<id>7</id>
<id>8</id>
<id>9</id>
</ids>
</ids>
Run Code Online (Sandbox Code Playgroud)
XML Doc#2
<ids>
<id>1</id>
<id>2</id>
<id>7</id>
<id>8</id>
<id>9</id>
</ids>
Run Code Online (Sandbox Code Playgroud)
如果我可以在id字段上加入这两个文件,我正在考虑使用linq.有没有更好的办法?我希望返回id#5和6.
我正在使用x-modem协议和133字节数据包从serialport读取文件.我在读那个
1 byte is SOH
2 byte packet number
3 byte nagative of packet number
next 128 bytes data
2 bytes CRC sent from other side.
Run Code Online (Sandbox Code Playgroud)
我必须计算128字节数据的CRC和从另一侧发送的2字节crc,我必须使其成为单字节,并且必须与我计算的crc共同计算.我怎么能在java中这样做?
我试过谷歌,但我找不到这个简单问题的答案.我讨厌自己无法解决这个问题,但我们走了.
如何在其中编写if语句or?
例如:
if raw_input=="dog" or "cat" or "small bird":
print "You can have this animal in your house"
else:
print "I'm afraid you can't have this animal in your house."
Run Code Online (Sandbox Code Playgroud) 按照这里的教程,我到达你运行的地方poll.was_published_today,我得到这个错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/myDir/mySite/polls/models.py", line 11, in was_published_today
return (self.pub_date() == datetime.date.today())
TypeError: 'datetime.datetime' object is not callable
Run Code Online (Sandbox Code Playgroud)
这是我的poll类的代码:
from django.db import models
import datetime
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_today(self):
return (self.pub_date() == datetime.date.today())
Run Code Online (Sandbox Code Playgroud)
我尝试了一些不同的东西,它总是在任何提及"日期时间"时窒息.
这段代码:
import datetime
datetime.date.today()
Run Code Online (Sandbox Code Playgroud)
当在解释器中运行时工作正常,正如预期的那样,但在我的文件中,它没有.有什么建议?
我正在尝试编写一个正则表达式来筛选大量数据.在找到某些东西后,我希望它匹配接下来的4个字符,无论它们是什么.我怎样才能做到这一点?
当我运行player.php时,它会给出这个错误:
Warning: Cannot modify header information - headers already sent by (output started
at /www/110mb.com/m/u/s/i/c/k/i/n/musicking/htdocs/player.php:8) in
/www/110mb.com/m/u/s/i/c/k/i/n/musicking/htdocs/player.php on line 24
Run Code Online (Sandbox Code Playgroud)
你能帮忙吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Player</title>
</head>
<body>
<?php
if(isset($_POST["song"])&& $_POST['song'] != "")
{
$song = $_POST["song"];
}
else {$song=array();}
for ($i="0"; $i<count($song); $i++) {
}
//start of new php codep
// create doctype
//$array = array(
// 'song.mp3','song.mp3','song.mp3',
//);
$dom = new DOMDocument("1.0");
// display document in …Run Code Online (Sandbox Code Playgroud) 我正在尝试实施受密码保护的首选项屏幕.我按下菜单按钮然后按设置按钮,而不是显示密码屏幕,FC和我收到此错误:
Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.john.websafe/com.john.websafe.Preferences}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
<snip>
Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
at android.app.ListActivity.onContentChanged(ListActivity.java:236)
at android.preference.PreferenceActivity.onContentChanged(PreferenceActivity.java:160)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:312)
at android.app.Activity.setContentView(Activity.java:1626)
at com.john.websafe.Preferences.onCreate(Preferences.java:19)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
... 11 more
Run Code Online (Sandbox Code Playgroud)
Preferences.java 第19行:
setContentView(R.layout.password);
Run Code Online (Sandbox Code Playgroud)
Password.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password" />
<EditText android:id="@+id/password" android:layout_width="fill_parent" …Run Code Online (Sandbox Code Playgroud) 我os.system用来将文件从系统复制到另一个系统.一个非常简单的程序的逻辑是在复制该文件后执行另一组命令.
问题是os.system实际上并没有等待文件被复制,而是执行下一行.这会给系统带来问题.我实际上可以提供一些等待功能,time.sleep()但是我们必须复制大小从500 MB到有时20 GB的文件,并且所用的时间是非常不同的.
解决方案是什么?我需要以某种方式告诉我的程序文件被复制,然后执行下一行.
我在这个PHP代码上遇到语法错误:
<snip>
$last = (isset($_GET['last']) && $_GET['last'] != '') ? $_GET['last'] : 0;
$query = "SELECT message_id, user_name, message, date_format(post_time, '%h:%i') AS post_time" .
" FROM message WHERE chat_id = " . db_input($_GET['chat']) . " AND message_id > " . $last . ";";
$message_query = db_query($query);
</snip>
Run Code Online (Sandbox Code Playgroud)
而且db_query:
function db_query($query, $link = 'db_link') {
global $$link;
$result = mysql_query(mysql_real_escape_string($query), $$link) or db_error($query, mysql_errno(), mysql_error());
return result;
}
Run Code Online (Sandbox Code Playgroud)
确切的错误是这样的:
You have an error in your SQL syntax; check the …Run Code Online (Sandbox Code Playgroud)