Hello
Hello! I am new to python and pretty new to programming (I have some expertise wit R statistical programming language). I am just starting, so my questions may be a little bit stupid. Can anyone suggest a good editor for python? Cheers! Dani -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! <>-- http://mail.python.org/mailman/listinfo/python-list
Re: Hello
Sorry, I forgot to mention that I am using Linux. In fact, my first test have been with gedit. Is there any way to directly run the Python code into the console? Cheers! Dani Bradley Hintze wrote: There are lots of great editors out there. It really depends on personal preference. It also depends on your OS. I us Mac OSX and like jEdit (my lab mate likes bbEdit). When I was on windows I liked notepad2. On linux i really like gEdit. Any of these will work great for a beginner! Bradley On Fri, Jul 9, 2010 at 12:31 PM, Dani Valverde wrote: Hello! I am new to python and pretty new to programming (I have some expertise wit R statistical programming language). I am just starting, so my questions may be a little bit stupid. Can anyone suggest a good editor for python? Cheers! Dani -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! -- http://mail.python.org/mailman/listinfo/python-list -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! <>-- http://mail.python.org/mailman/listinfo/python-list
Re: Hello
geremy condra wrote: On Fri, Jul 9, 2010 at 1:08 PM, Dani Valverde wrote: Sorry, I forgot to mention that I am using Linux. In fact, my first test have been with gedit. Is there any way to directly run the Python code into the console? Gedit has a plugin that brings up a python intepreter. Edit->Preferences->Plugins->python console I think. Geremy Condra I have this plugin enabled, but I don't know how to send the code to the console... Dani -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! <>-- http://mail.python.org/mailman/listinfo/python-list
Re: Hello
geremy condra wrote: On Sat, Jul 10, 2010 at 6:49 AM, Dani Valverde wrote: geremy condra wrote: On Fri, Jul 9, 2010 at 1:08 PM, Dani Valverde wrote: Sorry, I forgot to mention that I am using Linux. In fact, my first test have been with gedit. Is there any way to directly run the Python code into the console? Gedit has a plugin that brings up a python intepreter. Edit->Preferences->Plugins->python console I think. Geremy Condra I have this plugin enabled, but I don't know how to send the code to the console... type it in? Geremy Condra It could be a solution. But I am used to work with gEdit using the R statistical programming language plugin, and I am able to send the code to console instead of typing it in. Cheers! Dani -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! <>-- http://mail.python.org/mailman/listinfo/python-list
Declare self.cursor
Hello! I am working on a GUI to connect to a MySQL database using MySQLdb (code in attached file). I define the cursor in lines 55-66 in the OnLogin function within the LoginDlg class. /db= MySQLdb.connect(host='localhost', user=Username , passwd=pwd, db='Ornithobase') self.cursor = db.cursor()/ When I try to use the cursor on another part of the code (EditUser class, line 176) /sql = 'select substring_index(CURRENT_USER(),"@",1)' login.cursor.execute(sql)/ I get this error: /AttributeError: 'LoginDlg' object has no attribute 'cursor'/ You can check the code for details, I think is better. Cheers! Dani -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! #! /usr/bin/env python # OrnithobaseGUI.py import wx, MySQLdb, wx.lib.intctrl ID_HELP = 1 ID_ABOUT = 2 ID_LOG=3 ID_NEWUSER=4 ID_NEWUSER2=5 ID_DELUSER=6 ID_EDITUSER = 7 class LoginDlg(wx.Dialog): def __init__(self): wx.Dialog.__init__(self, None, -1, 'Login to Ornithobase 1.0b', size=(250,150)) # widgets userLbl = wx.StaticText(self, -1, 'Username:', size=(75, -1)) self.userTxt = wx.TextCtrl(self, -1, '', size=(200, -1)) passwordLbl = wx.StaticText(self, -1, 'Password:', size=(75, -1)) self.passwordTxt = wx.TextCtrl(self, -1, '',style=wx.TE_PROCESS_ENTER|wx.TE_PASSWORD, size=(200, -1)) loginBtn = wx.Button(self, -1, 'Login') clearBtn = wx.Button(self, wx.ID_CLEAR, 'Clear') self.Bind(wx.EVT_BUTTON, self.OnLogin,loginBtn) self.Bind(wx.EVT_BUTTON, self.OnClear, clearBtn) # sizer / layout userSizer = wx.BoxSizer(wx.HORIZONTAL) passwordSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) mainSizer = wx.BoxSizer(wx.VERTICAL) userSizer.Add(userLbl, 0, wx.ALL, 5) userSizer.Add(self.userTxt, 0, wx.ALL, 5) passwordSizer.Add(passwordLbl, 0, wx.LEFT|wx.RIGHT, 5) passwordSizer.Add(self.passwordTxt, 0, wx.LEFT, 5) btnSizer.Add(loginBtn, 0, wx.ALL, 5) btnSizer.Add(clearBtn, 0, wx.ALL, 5) mainSizer.Add(userSizer, 0, wx.ALL, 0) mainSizer.Add(passwordSizer, 0, wx.ALL, 0) mainSizer.Add(btnSizer, 0, wx.ALL, 5) # Logged in variable self.loggedIn = False self.SetSizer(mainSizer) self.Fit() self.Layout() def OnLogin(self, event): Username = self.userTxt.GetValue() pwd = self.passwordTxt.GetValue() try: db= MySQLdb.connect(host='localhost', user=Username , passwd=pwd, db='Ornithobase') self.cursor = db.cursor() print 'Connected' dlg = wx.MessageDialog(None, 'You are logged in', 'Info', wx.OK) dlg.ShowModal() self.Destroy() except: self.userTxt.Clear() self.passwordTxt.Clear() Errordlg = wx.MessageDialog(None, 'Connection failed', 'Error', wx.OK | wx.ICON_ERROR) print 'Connection failed' Errordlg.ShowModal() def OnClear(self, event): self.userTxt.Clear() self.passwordTxt.Clear() class NewUserDlg(wx.Dialog): def __init__(self): wx.Dialog.__init__(self, None, -1, 'Create new user', size=(400, 335)) #Define main panel panel = wx.Panel(self, -1) #Define sizers #Vertical sizers vbox = wx.BoxSizer(wx.VERTICAL) #Horizontal sizers NameSizer = wx.BoxSizer(wx.HORIZONTAL) FamilyNameSizer = wx.BoxSizer(wx.HORIZONTAL) eMailSizer = wx.BoxSizer(wx.HORIZONTAL) UsernameSizer = wx.BoxSizer(wx.HORIZONTAL) PasswdSizer = wx.BoxSizer(wx.HORIZONTAL) RepeatPasswdSizer = wx.BoxSizer(wx.HORIZONTAL) BtnSizer = wx.BoxSizer(wx.HORIZONTAL) Name = wx.StaticText(panel, -1, 'Name:', size=(100, -1)) self.NameTxt = wx.TextCtrl(pa
SetGridCursor not working?
Hello! I have a table with some rows and cells (code at the end), and created a function which searches for text inside the cells and returns the row number where the text is (to simplify the example, only English Name is working). Then, it should set the grid cursor focus to that row (I want to use the wx.grid.Grid.SelectRows style when created the wx.Grid, but to reduce the number of variables I don't use it in the example). To set the cursor focus, I am using def OnSearch(self, event): CommonName = self.CommonNameTXT.GetValue() if CommonName != '': ind = self.parent.EnglishNameList.index(CommonName) self.parent.SpeciesGrid.SetGridCursor(ind, 0) self.parent.SpeciesGrid.MakeCellVisible(ind,0) Theoretically, it should work using only the SetGridCursor method, however somewhere I have read that it will not work unless you also use the MaceCellVisible method as well. Anyway, it does not work at all. Can anyone help? Dani -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! <>-- http://mail.python.org/mailman/listinfo/python-list
Auto size wx.StaticText
Hello! Is there a way to automatically set the size of a wx.StaticText to fit its content? Cheers! Dani -- Daniel Valverde Saubí c/Joan Maragall 37 4 2 17002 Girona Spain Telèfon mòbil: +34651987662 e-mail: dani.valve...@gmail.com http://www.acrocephalus.net http://natupics.blogspot.com Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES! Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU! <>-- http://mail.python.org/mailman/listinfo/python-list