1,105,295 Community Members

Running Python on Ubuntu

Member Avatar
pyguy62
Posting Whiz
346 posts since Aug 2011
Reputation Points: 23 [?]
Q&As Helped to Solve: 19 [?]
Skill Endorsements: 0 [?]
 
0
 

I'm having an issue getting python 3.2 to recognize files in ubuntu, it's the first time I've tried to code while running it. A specific example of the issue is when setting an .ico to be a bitmap logo for a Frame in tkinter it's claiming that there it's not defined...

Traceback (most recent call last):
  File "/home/joshua/Python/Python-3.2.2/gpytact17.py", line 1617, in <module>
   [B] start.iconbitmap('pycontlog.ico')[/B]
  File "/usr/lib/python3.1/tkinter/__init__.py", line 1514, in wm_iconbitmap
    return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "pycontlog.ico" not defined

it's very odd to me, it doesn't actually seem like the error is just a matter of an issue finding the file "which is in the same folder by the way", but rather an issue of it claiming that a STRING is not defined. This is not an issue on Windows or Mac, any thoughts?

Just in case there's any confusion yes I bolded the part of the Error that showed my code, it's scary that I have to say that, but I've seen some awful questions around the net about stuff like that lately... Don't worry my Daniweb family, I haven't lost hope in you yet ;)

Member Avatar
pyTony
pyMod
6,103 posts since Apr 2010
Reputation Points: 818 [?]
Q&As Helped to Solve: 1,056 [?]
Skill Endorsements: 42 [?]
Moderator
Featured
 
0
 

Are you sure you have monocrome bitmap, I thought it must be .xbm format. Did you try to put '@' in front of file name, some net places mention it. http://epydoc.sourceforge.net/stdlib/Tkinter.Wm-class.html#wm_iconbitmap mention .ico only for default parameter for Windows.

Member Avatar
pyguy62
Posting Whiz
346 posts since Aug 2011
Reputation Points: 23 [?]
Q&As Helped to Solve: 19 [?]
Skill Endorsements: 0 [?]
 
0
 

okay, now a couple more issue have been realized, does focus_set() not work on ubuntu because the window doesn't go to the front nor does the focus get set on what I assign it to, also, SMTP doesn't seem to work nor does webbrowser, this is all pretty odd to me...

Member Avatar
woooee
Posting Maven
2,792 posts since Dec 2006
Reputation Points: 783 [?]
Q&As Helped to Solve: 836 [?]
Skill Endorsements: 12 [?]
 
0
 

because the window doesn't go to the front

You possibly want to provide a takefocus=True parameter, but I have no idea what widget you mean by "window". Without code your questions make no sense. Both SMTP and webbrowser work on my Slackware box.

Member Avatar
pyguy62
Posting Whiz
346 posts since Aug 2011
Reputation Points: 23 [?]
Q&As Helped to Solve: 19 [?]
Skill Endorsements: 0 [?]
 
0
 

pardon me woooee I was referring to a Frame, a toplevel window, I focus_set() for clarity I'll show you a bit of an example, which works on Windows, "I'll give takefocus a shot tomorrow, too tired right now

self.upanim=Button(self, text='Upload an image',command=self.con_image)
        self.upanim.grid(row=1,column=4)
        self.submit=Button(self,text='Add',command=self.addme)
        self.submit.bind('<Return>',self.addmejunction)
        self.submit.grid(row=12,column=2,columnspan=3)
    
      def con_image(self):
        self.file1=askopenfilename(filetypes=[('GIF FILES','*.gif'),('JPEG FILES','*.jpg')])
        try:
            self.new_image=ImageTk.PhotoImage(file=self.file1)
            self.picture['image']=self.new_image
            self.picture.grid(row=1,column=2)
            self.submit.focus_set()

Please not that that is not ALL of con_image nor is it all of the Frame, just wanted to show relevant parts.

Member Avatar
woooee
Posting Maven
2,792 posts since Dec 2006
Reputation Points: 783 [?]
Q&As Helped to Solve: 836 [?]
Skill Endorsements: 12 [?]
 
0
 

A toplevel does not automatically take focus. You have to set takefocus=True.

new_gui=Toplevel(root, takefocus=True)

There is nothing about SMTP or webbrowser in the last piece of code you posted, unless you are still trying to get the icon to load, in which case you store the id for the image in what appears to be a dictionary, then apply the entire dictionary to the grid (not the image entry).

self.new_image=ImageTk.PhotoImage(file=self.file1)
self.picture['image']=self.new_image
self.picture.grid(row=1,column=2)     ## self.picture['image'].grid, etc.
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: