用wxpython做ui_单击按钮如何在wxpython中制作其他窗口
這是一個工作示例:
import wx
########################################################################
class SecondFrame(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, title="Second Frame")
panel = wx.Panel(self)
txt = wx.StaticText(panel, label="I'm the second frame!")
########################################################################
class Prototype(wx.Frame):
#----------------------------------------------------------------------
def __init__(self, parent, title):
wx.Frame.__init__(self, None, title="First Frame", size=(1240,705))
self.UI()
self.Centre()
self.Show()
#----------------------------------------------------------------------
def UI(self):
self.panel1 = wx.Panel(self, -1)
self.sizer = wx.BoxSizer()
self.sizer.Add(self.panel1, 1, flag=wx.EXPAND)
b = wx.Button(self.panel1, label='second window', size=(180,100), pos=(650,25))
b.Bind(wx.EVT_BUTTON, self.OnB)
self.SetSizer(self.sizer)
#----------------------------------------------------------------------
def OnB(self, event):
frame = SecondFrame()
frame.Show()
#----------------------------------------------------------------------
app = wx.App(False)
Prototype(None, title='')
app.MainLoop()
我真的不建議混合大小調整器和絕對位置.您應該使用其中一個.我建議使用縮放器,除非您計劃制作無法調整尺寸的框架.
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的用wxpython做ui_单击按钮如何在wxpython中制作其他窗口的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用python定义一个员工类_pytho
- 下一篇: 郑州学python_郑州Python基础