Looking for new example wxpython AUI code - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html) +--- Forum: Bar (https://python-forum.io/forum-27.html) +--- Thread: Looking for new example wxpython AUI code (/thread-3730.html) |
Looking for new example wxpython AUI code - Larz60+ - Jun-18-2017 Hi, I have been playing with the new wxpython phoenix and like very much what I am finding. I am especially interested in the Advanced User Interface module that is a pure python rewrite by Andrea Gavana and can be found in wx.lib.agw.aui. There's some pretty powerful stuff here, dock-able windows and toolbars, resizable partitioned windows (or frames) and lots more. What's missing are documentation on a lot of the new features, even though in general the documentation is pretty good. Examples are few and far between (there's a few good ones in the demo app) just as an example, here's a screenshot of the AUI docking window manager: [attachment=193] click to enlarge I am hoping there will be some interest here, to try and get some sample code put together. I'm doing my best, and will create tutorials when I'm ready to do so. I'm currently working on the multi column window, and have created a generic basic manager window (code below). I am excited about what I am finding, I think it would be great if this could replace tkinter as a pre-packeged GUI. So if you're looking to play with something new, I'd love some company creating example code. For noobs, I have a tutorial on installation here https://python-forum.io/Thread-How-to-install-wxPython-Project-Phoenix-GUI-and-run-demo-from-scratch Here's the basic manager window as it stands now: import wx import wx.aui from win32api import GetSystemMetrics class BasicApp(wx.Frame): def __init__(self, parent=None, id=wx.ID_ANY, title='Basic App', pos=(50, 50), size=(400, 400), style=wx.DEFAULT_FRAME_STYLE, screen_factor=.5): self.screen_factor = screen_factor self.get_screen_info() wx.Frame.__init__( self, parent=None, id=wx.ID_ANY, title='Basic App', pos=(self.hoffset, self.voffset), size=(self.scwidth, self.scheight), style=wx.DEFAULT_FRAME_STYLE, name='BasicApp' ) self.initialize_components() self.CreateStatusBar() self.Show() def initialize_components(self): self._mgr = wx.aui.AuiManager() self._mgr.SetManagedWindow(self) self._perspectives = [] self._mgr.Update() self.Bind(wx.EVT_CLOSE, self.on_close) def get_screen_info(self): self.screen_width = GetSystemMetrics(0) self.screen_height = GetSystemMetrics(1) self.scwidth = int(self.screen_width * self.screen_factor) self.scheight = int(self.screen_height * self.screen_factor) self.hoffset = int((self.screen_width * .2) / 2) self.voffset = int((self.screen_height * .2) / 2) def on_close(self, event): self._mgr.UnInit() del self._mgr self.Destroy() def main(): app = wx.App() BasicApp() # frame.Show(True) app.MainLoop() if __name__ == '__main__': main() RE: Looking for new example wxpython AUI code - Larz60+ - Jun-18-2017 I should have explained that the Basic Manager window is to be used as a template to quickly get a foundation for a new application during the development stage, and should later be replaced with more application specific code. Also, the screen_factor argument to __init__ determines the size of the main screen. The default is .5 which relates to 50% of the users screen size. This can be modified as desired. This one 'feature' limits usage (until I figure out how to do it with Linux and OS-X) to MS windows. If you remove that code, everything should work (Unless some of the docking code is specific to MS) on Linux and OS-X, but I haven't tested this theory. I made some (slight ) modifications to the original:
New Listing: import wx import wx.aui from win32api import GetSystemMetrics import os """ The BasicApp can be used to set the empty Framework for an AUI application. Usage: import wx import wx.aui import BasicApp class TryAuiFramemanager(object): def __init__(self): BasicApp.__init__(title='RFC Viewer') def main(): app = wx.App() TryAuiFramemanager() app.MainLoop() if __name__ == '__main__': main() """ class BasicApp(wx.Frame): def __init__(self, parent=None, id=wx.ID_ANY, title='Basic App', pos=(50, 50), size=(400, 400), style=wx.DEFAULT_FRAME_STYLE, screen_factor=.5, name=os.path.basename(__file__)): program_name = os.path.basename(__file__) print('program_name: {}'.format(program_name)) self.screen_factor = screen_factor self.get_screen_info() wx.Frame.__init__( self, parent=parent, id=id, title=title, pos=(self.hoffset, self.voffset), size=(self.scwidth, self.scheight), style=style, name='BasicApp' ) self.initialize_components() self.CreateStatusBar() self.Show() def initialize_components(self): self._mgr = wx.aui.AuiManager() self._mgr.SetManagedWindow(self) self._perspectives = [] self._mgr.Update() self.Bind(wx.EVT_CLOSE, self.on_close) def get_screen_info(self): self.screen_width = GetSystemMetrics(0) self.screen_height = GetSystemMetrics(1) self.scwidth = int(self.screen_width * self.screen_factor) self.scheight = int(self.screen_height * self.screen_factor) self.hoffset = int((self.screen_width * .2) / 2) self.voffset = int((self.screen_height * .2) / 2) def on_close(self, event): self._mgr.UnInit() del self._mgr self.Destroy() def main(): app = wx.App() BasicApp() # frame.Show(True) app.MainLoop() if __name__ == '__main__': main()and sample usage: import wx import wx.aui import BasicApp class TryAuiFramemanager(object): def __init__(self): BasicApp.__init__(title='RFC Viewer') def main(): app = wx.App() TryAuiFramemanager() app.MainLoop() if __name__ == '__main__': main() |