我在和wxPython玩。我的理解是您需要以下物品: 1主“应用程序” 2框架(或我认为的主窗口) 三。框架内的面板 4面板中的小部件来做事情。你知道吗
当我运行代码时会弹出一个简单的窗口,我认为我可以接受第1点和第2点。然而,我尝试添加一个面板和一些基本的文本到它-但什么都没有显示。你知道吗
我的代码是:
import wx
class PDFApp(wx.App):
def OnInit(self): #Method used to define Frame & show it
self.frame = PDFFrame(parent=None, title="PDF Combiner", size=(300, 300))
self.frame.Show()
return True
class PDFFrame(wx.Frame):
def _init_(self, parent, title):
super(PDFFrame, self).__init__(parent, title=title)
Panel = PDFPanel(self)
class PDFPanel(wx.Panel):
def _init_(self, parent):
super(PDFPanel, self).__init__(parent)
self.Label = wx.StaticText(self, label="hello")
App = PDFApp()
App.MainLoop()
指出我的错误/遗漏-非常感谢!你知道吗
您的代码很不传统,因为
wx.App
通常只是app = wx.App()
但是,
_init_
应该是__init__
,不要使用可能与保留字或内部冲突的变量名。i、 例如
Panel
或Label
以及App
。以下应起作用。你知道吗
编辑:
我比较守旧(而且自学成才),所以我会编写这样简单的代码,比如:
相关问题 更多 >
编程相关推荐