用wxpython编写登录界面_使用wxPython在用户界面上编写文本(Writing a text on the user interface using wxPython)...

使用wxPython在用户界面上编写文本(Writing a text on the user interface using wxPython)

I want to add some text on the user interface to show the current iteration at each step. Something like the following example. How can I do that ?

5hKUV.png

原文:https://stackoverflow.com/questions/19029306

2020-01-03 22:02

满意答案

您可能想要做的是将其添加到on_redraw_timer方法。 每次更新绘图时它似乎都会触发,所以我认为这也是你想要写入文本控件的地方。

如果暂停,请确保停止写作。

What you probably want to do is add that to the on_redraw_timer method. It appears to fire every time the plot is updated, so I would think that that would be where you'd want to write to your text control as well.

Just make sure you stop writing if it is paused.

2013-09-26

相关问答

我在第2天一直在研究同一本书。 我相信内容已经过时了。 如果您将GetPosition()更改为 value = event.GetEventObject()。GetValue() 是正确的。 我可以确认它适用于Python 2.7.11。 耶利米 I've been working through that same book Python in a Day 2. I believe the content is already outdated. If you change the line ...

这是一个简单的例子,基本上可以满足您的需求: import wx

########################################################################

class MyFrame(wx.Frame):

""""""

#----------------------------------------------------------------------

def __init__(self):

...

您应该尝试Boa Constructor - 它已过时 - 但它针对的是WX - http://boa-constructor.sourceforge.net/ You should try Boa Constructor - it is dated - but it is targeted at WX - http://boa-constructor.sourceforge.net/

您可能想要做的是将其添加到on_redraw_timer方法。 每次更新绘图时它似乎都会触发,所以我认为这也是你想要写入文本控件的地方。 如果暂停,请确保停止写作。 What you probably want to do is add that to the on_redraw_timer method. It appears to fire every time the plot is updated, so I would think that that would be where you...

您应该能够捕获wx.CLOSE事件并阻止关闭对话框。 但是,我相信你最好使用向导式方法。 在第一步中,您将检查数字,然后单击“下一步”。 然后你会接受名称并关闭对话框。 我觉得这对用户来说是更自然的流程。 我把一个有趣的小例子放在一起,但你会注意到我没有以任何有意义的方式保存数据。 你想要自己添加: import wx

########################################################################

class MyDialog(w...

你不能。 这是用户的计算机,他们可以复制他们可以看到的任何数据。 现在,您可以通过截取像Control-A和Control-C这样的键的JavaScript来惹恼他们,但我讨厌这么多,我不会告诉您如何去做。 你可以使我喜欢的所有东西都变得冷静下来! 我想一个很好的中间基础是检测用户何时试图复制并且不允许它,但是沿着“嘿,你是否试图导出数据?”的行显示某种消息?尝试在那里的导出按钮 - >” You cannot. It is the user's computer and they can cop...

这是我正在寻找的另一种简单方法: import wx

def ask(parent=None, message='', default_value=''):

dlg = wx.TextEntryDialog(parent, message, defaultValue=default_value)

dlg.ShowModal()

result = dlg.GetValue()

dlg.Destroy()

return result

# Initialize...

首先,确保只需使用Python即可下载所需的数据。 然后使用单个按钮创建一个wxPython GUI。 在该按钮的处理程序中,让它调用可以下载所需数据的脚本。 如果这导致您的GUI无响应,那么您将需要使用线程进行下载。 如果是这样的话我推荐以下文章: http://www.blog.pythonlibrary.org/2010/05/22/wxpython-and-threads/ http://wiki.wxpython.org/LongRunningTasks 好的,现在你已经适当地下载了数据...

您可能希望查看建议选项的组合框 。 我希望这是你在想的。 You might want to look at Combo Box that Suggests Options. I hope this is what you were thinking of.

StaticText的静态部分实际上与移动...甚至可变性无关,而是从用户的角度看它是静态的(即它们不能改变它) def run_st(self):

global i

i = (i+1)%4

self.timer.Restart(1000)

if not hasattr(self,"sT"):

self.sT = wx.StaticText(self.widgetPanel, -1, '1', size=(20,20))

self.s...

相关文章

Open [Tomcat install dir]\tomcat-users.xmlfor editi

...

本人使用Swing开发图形界面,最近了解到XUL技术,知道可以通过编辑XML文档来定义各种Swing组

...

“Aschemaisacollectionofdatabaseobjects.Aschemaisown

...

官方文档里面说得比较明白,schema是数据对象的集合,包括像表、视图、索引、同义词等等都可以说是sc

...

Windowsis an extremely effective and a an efficient

...

一、中文分词:分词就是利用计算机识别出文本中词汇的过程。 1.典型应用:汉字处理:拼音输入法、手写识别

...

http://spark-project.org/ 项目首页 http://shark.cs.berk

...

网页上有很多功能是通过链接方式传递参数,这种功能链接普通样式就是一个超链接退出,如果将超链接的样式变成

...

Data Week: Becoming a data scientist Data Pointed,

...

最新问答

如果启用了复制处理程序,请确保将其置于其中一个安全角色之后。 我见过人们做的另一件事是在不同的端口上运行admin。 最好在需要auth的页面上使用SSL,这样你就不会发送明确的密码,因此管理和复制将发生在8443上,而常规查询将在8080上发生。 如果您要签署自己的证书,请查看此有用的SO页面: 如何在特定连接上使用不同的证书? I didn't know that /admin was the context for SOLR admin because /admin does not re

第一:在您的样本中,您有: 但是你在询问 //td[@class=‘CarMiniProfile-TableHeader’] (注意TableHeader中的大写'T')。 xpath区分大小写。 第二:通过查询// td [@ class ='CarMiniProfile-TableHeader'] / td,你暗示你在外部td中有一个'td'元素,而它们是兄弟姐妹。 有很多方法可以在这里获得制作和模型

这是你的答案: http://jsfiddle.net/gPsdk/40/ .preloader-container { position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; background: #FFFFFF; z-index: 5; opacity: 1; -webkit-transition: all 500ms ease-out;

问题是,在启用Outlook库引用的情况下, olMailItem是一个保留常量,我认为当您将Dim olMailItem as Outlook.MailItem ,这不是问题,但是尝试设置变量会导致问题。 以下是完整的解释: 您已将olMailItem声明为对象变量。 在赋值语句的右侧,在将其值设置为对象的实例之前,您将引用此Object 。 这基本上是一个递归错误,因为你有对象试图自己分配自己。 还有另一个潜在的错误,如果之前已经分配了olMailItem ,这个语句会引发另一个错误(可能是

我建议使用wireshark http://www.wireshark.org/通过记录(“捕获”)设备可以看到的网络流量副本来“监听”网络上发生的对话。 当您开始捕获时,数据量似乎过大,但如果您能够发现任何看起来像您的SOAP消息的片段(应该很容易发现),那么您可以通过右键单击并选择来快速过滤到该对话'关注TCP Stream'。 然后,您可以在弹出窗口中查看您编写的SOAP服务与Silverlight客户端之间的整个对话。 如果一切正常,请关闭弹出窗口。 作为一个额外的好处,wireshar

Android默认情况下不提供TextView的合理结果。 您可以使用以下库并实现适当的aligntment。 https://github.com/navabi/JustifiedTextView Android Does not provide Justified aligntment of TextView By default. You can use following library and achieve proper aligntment. https://github.com/

你的代码适合我: class apples { public static void main(String args[]) { System.out.println("Hello World!"); } } 我将它下载到c:\ temp \ apples.java。 以下是我编译和运行的方式: C:\temp>javac -cp . apples.java C:\temp>dir apples Volume in drive C is HP_PAV

12个十六进制数字(带前导0x)表示48位。 那是256 TB的虚拟地址空间。 在AMD64上阅读wiki(我假设你在上面,对吗?)架构http://en.wikipedia.org/wiki/X86-64 12 hex digits (with leading 0x) mean 48 bits. That is 256 TB of virtual address space. Read wiki on AMD64 (I assume that you are on it, right?) ar

这将取决于你想要的。 对象有两种属性:类属性和实例属性。 类属性 类属性对于类的每个实例都是相同的对象。 class MyClass: class_attribute = [] 这里已经为类定义了MyClass.class_attribute ,您可以使用它。 如果您创建MyClass实例,则每个实例都可以访问相同的class_attribute 。 实例属性 instance属性仅在创建实例时可用,并且对于类的每个实例都是唯一的。 您只能在实例上使用它们。 在方法__init__中定

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个简单的用 wxPython 实现登录界面和界面跳转的示例代码: ```python import wx class LoginPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.username_label = wx.StaticText(self, label='Username:', pos=(50, 50)) self.username_text = wx.TextCtrl(self, pos=(150, 50)) self.password_label = wx.StaticText(self, label='Password:', pos=(50, 100)) self.password_text = wx.TextCtrl(self, style=wx.TE_PASSWORD, pos=(150, 100)) self.login_button = wx.Button(self, label='Login', pos=(100, 150)) self.login_button.Bind(wx.EVT_BUTTON, self.on_login) def on_login(self, event): username = self.username_text.GetValue() password = self.password_text.GetValue() if username == 'admin' and password == 'admin': frame.switch_panel(LoginPanel, WelcomePanel) else: wx.MessageBox('Invalid username or password', 'Error', wx.OK | wx.ICON_ERROR) class WelcomePanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) welcome_label = wx.StaticText(self, label='Welcome!', pos=(50, 50)) class MainFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title='Login System', size=(300, 250)) self.Center() self.panel_dict = {} self.login_panel = LoginPanel(self) self.switch_panel(None, LoginPanel) def switch_panel(self, old_panel, new_panel_class): if old_panel: old_panel.Destroy() if new_panel_class in self.panel_dict: new_panel = self.panel_dict[new_panel_class] else: new_panel = new_panel_class(self) self.panel_dict[new_panel_class] = new_panel new_panel.Show() if __name__ == '__main__': app = wx.App() frame = MainFrame() frame.Show() app.MainLoop() ``` 在这个示例中,我们定义了两个面板:登录界面 `LoginPanel` 和欢迎界面 `WelcomePanel`。在登录界面中,我们添加了一个用户名输入框、一个密码输入框和一个登录按钮。当用户点击登录按钮时,我们获取输入的用户名和密码,如果用户名和密码都为 `admin`,则切换到欢迎界面;否则,弹出一个错误提示框。 我们还定义了一个 `MainFrame` 类,它继承自 `wx.Frame`,用于管理面板的切换。在 `MainFrame` 中,我们使用一个字典来保存已经创建的面板实例,这样可以避免重复创建。我们还定义了一个 `switch_panel` 方法,用于切换面板。当需要切换到一个新的面板时,我们先销毁旧面板,然后创建或从字典中获取新面板实例,最后显示新面板。 在 `MainFrame` 的 `__init__` 方法中,我们创建了 `LoginPanel` 面板并显示。在 `LoginPanel` 的 `on_login` 方法中,如果用户名和密码都为 `admin`,则调用 `frame.switch_panel` 方法将当前面板切换到 `WelcomePanel`。 通过这个示例,你可以了解到如何使用 wxPython 实现界面跳转。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值