这是我第一次真正坐下来尝试python 3,似乎失败了.我有以下两个文件:
config.py中定义了一些函数以及一些变量.我把它剥离到以下内容:
但是,我收到以下错误:
ModuleNotFoundError: No module named 'config'
Run Code Online (Sandbox Code Playgroud)
我知道py3约定是使用绝对导入:
from . import config
Run Code Online (Sandbox Code Playgroud)
但是,这会导致以下错误:
ImportError: cannot import name 'config'
Run Code Online (Sandbox Code Playgroud)
所以我不知道该怎么做......非常感谢任何帮助.:)
这只发生在Linux上(也可能是OS X,无法测试atm),在Windows上运行正常.
我有一个wx.ProgressDialog与主线程产生.我将工作发送到另一个线程,它会定期回调主线程中的回调函数,该函数将更新ProgressDialog,或者在工作结束时将其销毁.但是,当发生这种情况时,我在Linux上收到一条有趣的消息:
(python:12728): Gtk-CRITICAL **: IA__gtk_window_set_modal: assertion 'GTK_IS_WINDOW (window)' failed
该对话框确实关闭,但如果我再次尝试生成它,它看起来已经差不多完成了.有时,seg错误也会跟随此消息.
我试图在这里使用精简版本来模拟它:
import wxversion
wxversion.select("2.8")
import wx
import sys
import threading
MAX_COUNT = 100
## This class is in a different area of the codebase and
class WorkerThread(threading.Thread):
def __init__(self, callback):
threading.Thread.__init__(self)
self.callback = callback
def run(self):
# simulate work done. IRL, this calls another function in another
# area of the codebase. This function would generate an XML document,
# which loops through a list of items and …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在文本字段中格式化数字,如下所示:
123,456,789
我知道有很多jQuery插件可以做到这一点,但是,它们都改变了实际值.我只是希望它看起来格式化,而不是格式化发送.
例如,如果我输入23845
我的文本字段,我希望它可视地转换为23,845
,但是当我发送表单时,我希望它发送为23845
.
有谁知道我怎么能做到这一点?我见过的所有其他解决方案都会改变实际提交的值.
我有一个表,使用bootstrap,用于:nth-child
设置交替表行的样式.但是,每当我用jQuery删除一行时.hide()
,交替的行都会中断.
HTML:
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<table id='t1' class="table table-bordered table-striped table-condensed table-hover table-even-widths">
<thead>
<tr>
<th>Heading A</th>
<th>Heading B</th>
<th>Heading C</th>
</tr>
</thead>
<tbody>
<tr id='r1'>
<td>0</td>
<td>b</td>
<td>c</td>
</tr>
<tr id='r2'>
<td>1</td>
<td>b</td>
<td>c</td>
</tr>
<tr id='r3'>
<td>2</td>
<td>b</td>
<td>c</td>
</tr>
<tr id='r4'>
<td>3</td>
<td>b</td>
<td>c</td>
</tr>
<tr id='r5'>
<td>4</td>
<td>b</td>
<td>c</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
JS:
$('#r4').hide();
我想知道是否有一种简单的方法可以使用新配置重置表.我总是可以创建自己的类.even
和.odd
类,并在每次更新后过滤表以删除并重新应用类,但希望有一个更优雅的解决方案.