matthieuvb Posted February 6, 2011 Posted February 6, 2011 (edited) why this script is not working: import wx import tkFileDialog from Tkinter import * ID_A = 101 class CreateFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, "Notepad python", size = (500, 400)) self.panl = wx.Panel(self) self.statusbar = self.CreateStatusBar() self.menubar = wx.MenuBar() self.menu1 = wx.Menu() self.menu1.Append(ID_A, "Open", "Open a file") self.menubar.Append(self.menu1, "file") self.SetMenuBar(self.menubar) self.txtctrl = wx.TextCtrl(self.panl, pos = (10, 10), size = (200, 300), style = wx.TE_MULTILINE) self.Connect(ID_A, -1, wx.wxEVT_COMMAND_MENU_SELECTED, self.openfileedit) def openfileedit(self, event): OFO = Tk() OFO.withdraw() self.filepath = tkFileDialog.askopenfilename() self.fileobj = open(self.filepath, "r") self.txtctrl.Clear() self.txtctrl.AppendText(self.fileobj.read()) if __name__ == "__main__": app = wx.App() frame = CreateFrame(parent = None, id = -1) frame.Show() app.MainLoop() I use python27. PS: whats a good python forum? Edited February 6, 2011 by Matthieuautoitscripter [font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]
James Posted February 6, 2011 Posted February 6, 2011 Hi, This isn't a Python forum, chat may have been better! James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
matthieuvb Posted February 6, 2011 Author Posted February 6, 2011 i now, but i do'nt know a good python forum [font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]
Mat Posted February 6, 2011 Posted February 6, 2011 http://stackoverflow.com/questions/316325/import-wx-fails-after-installation-of-wxpython-on-windows-xp AutoIt Project Listing
matthieuvb Posted February 6, 2011 Author Posted February 6, 2011 (edited) http://stackoverflow.com/questions/316325/import-wx-fails-after-installation-of-wxpython-on-windows-xp thats not the problem. (i think) the problem is this: tkFileDialog.askopenfilename() if i press the open menu, i get this error: Traceback (most recent call last): File "C:\Users\Matthieu\Documents\Python\GUI.py", line 25, in openfileedit self.filepath = tkFileDialog.askopenfilename() AttributeError: 'module' object has no attribute 'askopenfilename' i dont know what i doing wrong! i use win_7 x86 Edited February 6, 2011 by Matthieuautoitscripter [font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]
Valik Posted February 7, 2011 Posted February 7, 2011 (edited) Would you take your car into the shop and say "Hey, my car's not working" and leave? If so you should be shot. Likewise, you should be shot for this thread. Let me give you two examples of why your "script" (Python is a programming language, not a scripting language, therefore you write programs, not scripts):I don't have Python 2.7 installed (I didn't look to see if you are using any specific features not available in earlier versions).I don't have wxPython installed.Did these two problems help you? No? Maybe in the future you'll provide useful information then...Locking this thread, not because it doesn't belong on this forum (There's nothing wrong with asking a Python question). I'm locking it for the simple stupidity in the way it's presented. Also because I'm a dick and that's how I roll. Edited February 7, 2011 by Valik
Recommended Posts