954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Running Python on Ubuntu

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>
   <strong> start.iconbitmap('pycontlog.ico')</strong>
  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 ;)

pyguy62
Posting Whiz
353 posts since Aug 2011
Reputation Points: 34
Solved Threads: 19
 

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.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

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...

pyguy62
Posting Whiz
353 posts since Aug 2011
Reputation Points: 34
Solved Threads: 19
 
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.

woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 

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.

pyguy62
Posting Whiz
353 posts since Aug 2011
Reputation Points: 34
Solved Threads: 19
 


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.
woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: