Posts

Showing posts with the label wxPython

wxPython - ENTER/RETURN key binding for a wx.Dialog

To set ENTER / RETURN key binding for a wx.Dialog, add the following to a button of that dialog: self.mybutton.SetDefault() For example: class LoginDialog (wx.Dialog):     def __init__ (self, parent, id=-1, title='Login',                  text='Please type your username and password:',                  username=''):         size = (400, 200)         wx.Dialog.__init__(self, parent, id, title, size=size)         self.panel = LoginPanel(self)         sizer = wx.GridSizer(1, 1)         sizer.Add(self.panel, flag=wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)         self.SetSizer(sizer)         self.Bind(wx.EVT_CLOSE, self.OnClose, self)...

wxPython + Django - Basic authentication in wxPython with Django

The beauty of Python and any other OOP programing languages is the reusable functionality. So, I reuse the authentication module of Django to add a basic security layer for my wxPython application: + Authenticate a user with Django (django.contrib.auth.authenticate) + Save the session to a file names 'cred' + Read the 'cred' file to verify if that user has the privilege. * The main frame: class HomeFrame(wx.Frame):     def __init__(self):         wx.Frame.__init__(             self,             parent=None,             title='My wxPython application',             size=wx.DisplaySize(),         )         self.panel = HomePanel(self)         sizer = wx.GridSizer(1, 1) ...

wxPython - Using Save File Dialog

I use this snippet to create a dialog for saving file using wxPython library: class ReportDialog(wx.Dialog):     def __init__(self, parent, id=-1, title='Report',                  text='Select Type Of Report'):         size = (350, 200)         wx.Dialog.__init__(self, parent, id, title, size=size)         self.panel = ReportPanel(self)         sizer = wx.GridSizer(1, 1)         sizer.Add(self.panel, flag=wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)         self.SetSizer(sizer)         self.Show() REPORT_TYPES = ['All', 'Teachers', 'Students', 'Parents'] class ReportPanel(wx.Panel):     def __init__(self, parent):         wx.Panel.__init__(self, parent) ...

How to install wxPython inside a virtualenv environment

python-pip does not contain wxPython module. So, to use it inside an virtualenv environment (e.g.: /home/.venv/myenv/): 1. Install it system-wide: $ sudo apt-get install python-wxgtk2.8 2. Make a symbolic link of wxPython to the virtualenv: $ ln -s /usr/lib/python2.7/site-packages/wx* /home/.venv/myenv/lib/python2.7/site-packages/ Update: In xUbuntu 12.04: $ ln -s /usr/lib/python2.7/dist-packages/wx* /home/.venv/myenv/lib/python2.7/site-packages/