class DocArea(VPanel): doc_tab = None def __init__(self, presenter, parent): self.presenter = presenter VPanel.__init__(self, parent) self.SetBackgroundColour(wx.Colour(255, 255, 255)) #----- First row row_hbox = wx.BoxSizer(HORIZONTAL) self.corner = RulerCorner(presenter, self) row_hbox.Add(self.corner) self.hruler = Ruler(presenter, self, HORIZONTAL) row_hbox.Add(self.hruler, 1, EXPAND) self.box.Add(row_hbox, 0, EXPAND) #----- Second row row_hbox = wx.BoxSizer(HORIZONTAL) self.vruler = Ruler(presenter, self, VERTICAL) row_hbox.Add(self.vruler, 0, EXPAND) vbox = wx.BoxSizer(VERTICAL) hbox = wx.BoxSizer(HORIZONTAL) vbox.Add(hbox, 1, EXPAND) self.canvas = AppCanvas(presenter, self) hbox.Add(self.canvas, 1, EXPAND) self.vscroll = wx.ScrollBar(self, wx.ID_ANY, style=wx.SB_VERTICAL) hbox.Add(self.vscroll, 0, EXPAND) #----- Bottom row bottom_hbox = wx.BoxSizer(HORIZONTAL) bottom_vbox = wx.BoxSizer(VERTICAL) self.hscroll = wx.ScrollBar(self, wx.ID_ANY, style=wx.SB_HORIZONTAL) bottom_hbox.Add(self.hscroll, 1, EXPAND) self.bottom_corner = VPanel(self) size = self.vscroll.GetSize()[0] self.viewer = DocViewer(presenter, self, (size, size)) self.bottom_corner.add(self.viewer) bottom_hbox.Add(self.bottom_corner) vbox.Add(bottom_hbox, 0, EXPAND) row_hbox.Add(vbox, 1, EXPAND) self.box.Add(row_hbox, 1, EXPAND) self.canvas._set_scrolls(self.hscroll, self.vscroll) def destroy(self): objs = [ self.doc_tab, self.hruler, self.vruler, self.corner, self.canvas ] for obj in objs: obj.destroy() items = self.__dict__.keys() for item in items: self.__dict__[item] = None
class DocArea(VPanel): doc_tab = None def __init__(self, presenter, parent): self.presenter = presenter VPanel.__init__(self, parent) self.SetBackgroundColour(wx.Colour(255, 255, 255)) #----- First row row_hbox = wx.BoxSizer(HORIZONTAL) self.corner = RulerCorner(presenter, self) row_hbox.Add(self.corner) self.hruler = Ruler(presenter, self, HORIZONTAL) row_hbox.Add(self.hruler, 1, EXPAND) self.box.Add(row_hbox, 0, EXPAND) #----- Second row row_hbox = wx.BoxSizer(HORIZONTAL) self.vruler = Ruler(presenter, self, VERTICAL) row_hbox.Add(self.vruler, 0, EXPAND) vbox = wx.BoxSizer(VERTICAL) hbox = wx.BoxSizer(HORIZONTAL) vbox.Add(hbox, 1, EXPAND) self.canvas = AppCanvas(presenter, self) hbox.Add(self.canvas, 1, EXPAND) self.vscroll = wx.ScrollBar(self, wx.ID_ANY, style=wx.SB_VERTICAL) hbox.Add(self.vscroll, 0, EXPAND) #----- Bottom row bottom_hbox = wx.BoxSizer(HORIZONTAL) bottom_vbox = wx.BoxSizer(VERTICAL) self.hscroll = wx.ScrollBar(self, wx.ID_ANY, style=wx.SB_HORIZONTAL) bottom_hbox.Add(self.hscroll, 1, EXPAND) self.bottom_corner = VPanel(self) size = self.vscroll.GetSize()[0] self.viewer = DocViewer(presenter, self, (size, size)) self.bottom_corner.add(self.viewer) bottom_hbox.Add(self.bottom_corner) vbox.Add(bottom_hbox, 0, EXPAND) row_hbox.Add(vbox, 1, EXPAND) self.box.Add(row_hbox, 1, EXPAND) self.canvas._set_scrolls(self.hscroll, self.vscroll) def destroy(self): objs = [self.doc_tab, self.hruler, self.vruler, self.corner, self.canvas] for obj in objs: obj.destroy() items = self.__dict__.keys() for item in items: self.__dict__[item] = None
# p.add(Label(p, 'Mac Toolbar Buttons:'), 0, flags, 5) # # p.add(MacTB_ActionButton(p, AppAction(wx.ID_NEW, self.repeat_test)), # 0, flags, 5) # # action = AppAction(wx.ID_NEW, self.repeat_test) # action.set_enable(False) # p.add(MacTB_ActionButton(p, action), 0, flags, 5) # action.update() # # actions = [AppAction(wx.ID_NEW, self.repeat_test), # AppAction(wx.ID_NEW, self.repeat_test), # AppAction(wx.ID_NEW, self.repeat_test)] # p.add(MacTB_ActionNestedButtons(p, actions), 0, flags, 5) # index = 0 # for action in actions: # if index == 1:action.set_enable(False) # action.update() # index += 1 # # self.add(p, 0, pflags) app = Application('Graphics widgets') mw = MainWindow(app.app_name, (700, 500)) p = VPanel(mw) mw.add(p, 1, ALL | EXPAND) panel = WidgetPanel(mw) p.add(panel, 1, ALL | EXPAND, 10) app.mw = mw app.run()
def build(self): flags = LEFT | CENTER pflags = ALL | EXPAND #---------Labels p = HPanel(self) props = [ ('Normal font', False, 0), ('Bold font', True, 0), ('-1 font', False, -1), ('+1 font', False, 1), ('+2 font', False, 2), ('+2 bold font', True, 2), ('+2 red bold font', True, 2, (255, 0, 0)), ] for item in props: p.pack(Label(p, *item), padding=5) self.pack(p, fill=True) self.pack(HLine(self), fill=True, padding=5) #---------HtmlLabels p = HPanel(self) p.pack(HtmlLabel(p, 'http://sk1project.org'), padding=5) p.pack(HtmlLabel(p, 'Download site', 'http://sk1project.org'), padding=5) self.pack(p, fill=True) self.pack(HLine(self), fill=True, padding=5) #---------Buttons p = HPanel(self) p.pack(Button(p, 'Native button'), padding=5) txt = 'Native default button' p.pack(Button(p, 'Native default button', default=True, tooltip=txt), padding=5) p.pack(Button(p, 'Native button with callback', onclick=self.test), padding=5) self.pack(p, fill=True) self.pack(HLine(self), fill=True, padding=5) #---------Checkboxes p = HPanel(self) p.add(Checkbox(p, 'Native checkbox'), 0, flags, 5) p.add(Checkbox(p, 'Native checkbox (checked)', True), 0, flags, 5) p.add(Checkbox(p, 'Checkbox with callback', onclick=self.test), 0, flags, 5) self.pack(p, fill=True, padding=5) self.pack(HLine(self), fill=True, padding=5) #---------Radiobuttons p = HPanel(self, border=BOTTOM, space=2) p.add(Radiobutton(p.panel, 'Native radiobutton', group=True), 0, flags, 5) p.add(Radiobutton(p.panel, 'Native radiobutton (selected)'), 0, flags, 5) p.add(Radiobutton(p.panel, 'Radiobutton with callback', onclick=self.test), 0, flags, 5) self.add(p, 0, pflags) #---------Combolist p = HPanel(self, border=BOTTOM, space=2) sample = ['zero', 'one', 'two', 'three', 'four five', 'six seven eight'] p.add(Label(p, 'Native combolist:'), 0, flags, 5) p.add(Combolist(p, items=sample), 0, flags, 5) p.add(Label(p, 'Native combolist with callback:'), 0, flags, 5) p.add(Combolist(p, items=sample, onchange=self.test), 0, flags, 5) self.add(p, 0, pflags) #---------Combobox p = HPanel(self, border=BOTTOM, space=2) sample = ['zero', 'one', 'two', 'three', 'four five', 'six seven eight'] p.add(Label(p, 'Native combobox:'), 0, flags, 5) p.add(Combobox(p, 'value', items=sample), 0, flags, 5) p.add(Label(p, 'Native combobox with callback:'), 0, flags, 5) p.add(Combobox(p, items=sample, width=15, onchange=self.test), 0, flags, 5) self.add(p, 0, pflags) #---------Text entry p = HPanel(self, border=BOTTOM, space=2) p.add(Label(p, 'Native text entry:'), 0, flags, 5) p.add(Entry(p, 'value', width=5), 0, flags, 5) p.add(Label(p, 'Native text entry with callback:'), 0, flags, 5) p.add(Entry(p, 'value', onchange=self.test), 0, flags, 5) self.add(p, 0, pflags) #---------Multiline Text entry p = HPanel(self, border=BOTTOM, space=2) p.add(Label(p, 'Multiline text entry:'), 0, flags, 5) p.add(Entry(p, 'value', size=(150, 50), multiline=True), 0, flags, 5) p.add(Label(p, 'Multiline text entry with callback:'), 0, flags, 5) p.add(Entry(p, 'value', size=(150, 50), multiline=True, onchange=self.test), 0, flags, 5) self.add(p, 0, pflags) #---------Spin p = HPanel(self, border=BOTTOM, space=2) p.add(Label(p, 'Native spin control:'), 0, flags, 5) p.add(Spin(p, 1, (0, 90), onchange=self.test), 0, flags, 5) p.add(Label(p, 'Float spin control:'), 0, flags, 5) self.spin = FloatSpin(p.panel, 1.3, (0.0, 90.0), 0.01, 3, width=5, onchange=self.test) p.add(self.spin, 0, flags, 5) p.add(Button(p, 'Get value', onclick=self.test_spin), 0, flags, 5) self.add(p, 0, pflags) #---------Slider p = HPanel(self, border=BOTTOM, space=2) p.add(Label(p, 'Native slider:'), 0, flags, 5) p.add(Slider(p.panel, 25, (0, 255), onchange=self.test), 0, flags, 5) self.add(p, 0, pflags) #---------Labeled panel p = HPanel(self) panel = LabeledPanel(p, 'The panel') panel.add((0, 50), 0, flags, 0) panel.add(Label(p, 'Native Labeled Panel'), 0, flags, 0) p.box_add(panel.box, 0, flags, 5) panel = LabeledPanel(p) panel.add((0, 50), 0, flags, 0) panel.add(Label(p, 'Headless Labeled Panel'), 0, flags, 0) p.box_add(panel.box, 0, flags, 5) p.add(VLine(p), 0, ALL | EXPAND, 3) nb = Notebook(p) page = VPanel(nb) page.add((50, 100)) nb.add_page(page, 'First page') page = VPanel(nb) page.add((50, 100)) nb.add_page(page, 'Second page') p.add(nb, 1, ALL | EXPAND, 3) self.add(p, 0, pflags)
p.box_add(panel.box, 0, flags, 5) panel = LabeledPanel(p) panel.add((0, 50), 0, flags, 0) panel.add(Label(p, 'Headless Labeled Panel'), 0, flags, 0) p.box_add(panel.box, 0, flags, 5) p.add(VLine(p), 0, ALL | EXPAND, 3) nb = Notebook(p) page = VPanel(nb) page.add((50, 100)) nb.add_page(page, 'First page') page = VPanel(nb) page.add((50, 100)) nb.add_page(page, 'Second page') p.add(nb, 1, ALL | EXPAND, 3) self.add(p, 0, pflags) app = Application('wxWidgets') mw = MainWindow('Basic widgets', (750, 550)) p = VPanel(mw) mw.add(p, 1, ALL | EXPAND) panel = WidgetPanel(mw) p.add(panel, 1, ALL | EXPAND, 10) app.mw = mw app.run()