Sign in to follow this  
Followers 0
matthieuvb

python the programming language - 2 questions

6 posts in this topic

#1 ·  Posted (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 by Matthieuautoitscripter

[font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]

Share this post


Link to post
Share on other sites



i now, but i do'nt know a good python forum


[font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]

Share this post


Link to post
Share on other sites

http://stackoverflow.com/questions/316325/import-wx-fails-after-installation-of-wxpython-on-windows-xp

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Matthieuautoitscripter

[font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by Valik

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0