Last active
August 29, 2015 14:14
-
-
Save driscollis/5ede5901031aeb522807 to your computer and use it in GitHub Desktop.
wxPython - expanding controls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import wx | |
| import os | |
| class MainWindow(wx.Frame): | |
| def __init__(self,parent,title): | |
| wx.Frame.__init__(self, parent, title=title) | |
| self.workbookDir = r'C:\Users\Nick\Desktop' | |
| self.workbookName = 'rota.xlsx' | |
| self.panel = wx.Panel(self) | |
| self.label = wx.StaticText(self.panel, label = 'Workbook path: ') | |
| self.filePathBox = wx.TextCtrl(self.panel) | |
| self.filePathBox.SetValue(self.workbookPath()) | |
| self.filePathBoxSizer = wx.BoxSizer(wx.HORIZONTAL) | |
| self.filePathBoxSizer.Add(self.label, 0, wx.EXPAND) | |
| self.filePathBoxSizer.Add(self.filePathBox, 1, wx.EXPAND) | |
| self.openButton = wx.Button(self.panel, wx.ID_OPEN, 'Open') | |
| #self.Bind(wx.EVT_BUTTON, self.OnOpen, self.openButton) | |
| self.panelSizer = wx.BoxSizer(wx.VERTICAL) | |
| self.panelSizer.Add((0, 0), 1, wx.EXPAND) | |
| self.panelSizer.Add(self.filePathBoxSizer, 0, wx.CENTER) | |
| self.panelSizer.Add((0, 0), 1, wx.EXPAND) | |
| self.panelSizer.Add(self.openButton, 0, wx.CENTER) | |
| self.panelSizer.Add((0, 0), 1, wx.EXPAND) | |
| self.panel.SetSizer(self.panelSizer) | |
| self.panelSizer.Fit(self.panel) | |
| self.panel.SetAutoLayout(True) | |
| self.Fit() | |
| self.Show() | |
| def workbookPath(self): | |
| return os.path.join(self.workbookDir, self.workbookName) | |
| app = wx.App(False) | |
| frame = MainWindow(None, "Invoice Generator") | |
| frame.Show(True) | |
| app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment