You are not logged in.
Pages: 1
Hi all!
I wrote a little program in Python. It calls a Bash shell script to do a little regex executions on a file (the _name_ of the file), then calls a separate python program to do some image editing on said file. Since most people (non-geek) are scared of the command line, I decided I better write a simple GUI frontend - which I did using Tkinter.
Here's the odd thing: when I start the GUI from a terminal, everything works just fine, but when I start the program by simply double clicking the icon, it does _not_ work.
My guess is that it has something to do with a lot of things that are read from the shell are _not_ being read when I double click, but I don't know this, and I don't really know how where to start looking.
Any input would be appreciated.
HMW
*I know this is not the Python forums, but this is the best FORUM.
Offline
A few things that spring to mind, some of which have tripped me up in the past....
(NB I'm not a pythonista or bash guru
)
What kind of "icon" are you double-clicking? Have you tried launching the app from a menu item or keybind? If that works then you won't need an icon 
Have you set the python version in the binbash line, or using the default ie
#!/usr/bin/env python<x>
or
#!/usr/bin/pythonI've got 3 python versions, so I'm wondering if your launcher is calling the wrong version for your Tk (which one do you have btw?)
Have you set a $PYTHONPATH? Maybe the launcher can't find the necessary modules
Just wondering - until someone who knows a lot more than me comes along.....
Artwork at deviantArt; Iceweasel Personas; GDM #! Themes;
SLiM #! Themes
Offline
If you want to simplify, python has a regex module. With the OS module, you can handle file names and operations. With this web site, you can test your python regex strings. http://www.pythonregex.com/. You can turn off the timeit checkmark probably.
Simplification might eliminate your problem, or at least bring you closer to where the problem lies.
I agree with you, this is the best forum of all.
Last edited by AlanD (2012-04-26 01:38:59)
Offline
Hi HMW
I agree use the re (regex Module)
http://docs.python.org/howto/regex.html
Secondly, make your py file executable...
chmod +x /path/filename.py Should take care of your run with a Mouse click issue.
As from a CLI you are calling via the py env
But from a FileManager GUI you need to make it Executable per permissions.
Take a look at and run this as a test making it +x first...
Note the 2nd line which I would suggest as it is possible to use encodings different than ASCII in Python source files....
So use this and pop open the small tk test window as an example..
I have pythontk 2.7 and tk 8.5 installed here..
Though I will primarily use PyQt..
Anyway this works fine when Mouse Clicked from Thunar...
EDIT: Opps! when I copy/pasted I dropped the last 6 lines, Fixed Now!
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
#Test a TKwidget
from Tkinter import Tk, Frame, BOTH
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent, background="white")
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("CrunchBang")
self.pack(fill=BOTH, expand=1)
def main():
root = Tk()
root.geometry("250x150+300+300")
app = Example(root)
root.mainloop()
if __name__ == '__main__':
main()
Last edited by sqlpython (2012-04-26 06:42:22)
OHCG #!, Wheezy,, Siduction-12, Bridge-Arch , Slackware & Sabayon X,
Offline
Thanks for your replies. In a bit of a hurry now, but...
The "icon" i click is made using py2app (yes, this program is for use on Mac OS X, sadly). Everything is executable as it should.
I have a feeling this problem is due to the hopping back & forth from the other programs I call... hmm...
Anyway, if any of y'all would like to check the program out, I'd be happy to send it to you. Maybe that would help?
Thanks all for your thoughts, appreciate it!
HMW
Offline
Sorry HMW... I am allergic to MACs and Strawberries. Both nice but there you have it. 
I have never used py2app. However many of the apps which will auto generate other apps have the possibility of needing DeBugging as we tinker with it's templates.
I took a quick Google and see that when dealing with launching a py2app creation there is indeed differences launching Command line vs. the FINDER.. see here and maybe this will give you a leg up..
OHCG #!, Wheezy,, Siduction-12, Bridge-Arch , Slackware & Sabayon X,
Offline
Sorry HMW... I am allergic to MACs and Strawberries.
Strawberries I like, the Mac not so much - it's not by my choice! Thanks for the link, I'll check it out!
Offline
Pages: 1
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.