Tartalomjegyzék

< wxPython GUI

wxPython Panel

Panel használata

Panel Példa:

panel.py
import wx
 
class MainFrame(wx.Frame):
    def __init__(self, parent):
        super().__init__(parent)
 
        self.initUI()
        self.initLayout()
 
    def initUI(self):
        self.panel1 = wx.Panel(self)
        self.textCtrl1 = wx.TextCtrl(self.panel1)
        self.button1 = wx.Button(self.panel1, label='Mehet')
 
    def initLayout(self):
        rootBox = wx.BoxSizer(wx.HORIZONTAL)
        rootBox.Add(self.textCtrl1)
        rootBox.Add(self.button1)
        self.panel1.SetSizer(rootBox)
 
class SimpleApp(wx.App):
    def OnInit(self):
        frame = MainFrame(None)
        frame.Show()
        return True
 
app = SimpleApp()
app.MainLoop()

Külön osztály

import wx
 
class ValamiPanel(wx.Panel):
    def __init__(self, parent):
        super().__init__(parent)
 
        self.initUI()
        self.initLayout()
 
    def initUI(self):
        pass
 
    def initLayout(self):
        pass

Kicsi minta

panel.py
import wx
 
class Panel1(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)
 
        btn = wx.Button(self, label='Mehet')
 
app = wx.App()
frame = wx.Frame(None, -1, 'Egy gomb', size=(400, 300))
Panel1(frame, -1)
frame.Show()
app.MainLoop()