GUI Program Error
Hi, I'm using the "Learning to Program" GUI tutorial on http://www.freenetpages.co.uk/hp/alan.gauld/ and am trying to write my first GUI. However, the code the tutorial gives for starting by making a window: import Tkinter top = Tkinter.Tk() dir(top) Does not work. The Python interpreter does not complain about anything, but the window the tutorial promises will apperar will not. I'm using Python 2.4.2 and the Eric 3.7.0 IDE on Ubuntu 5.10. Anybody know what to do? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI Program Error
Thanks, this works. Now, since the tutorial I was using is clearly rubbish, any better ones? For a (relative) newbie please. Also, how do I code a GUI Hello World program? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Learning Python
I know this is probably a stupid question, but I'm learning Python, and am trying to get the if function to work with letters/words. Basicly, I'm trying to write a script that when run, says Please enter your name: Then, if the user types myself as the name , the output is OK. Thats all I want it to do (remember, Im just new). The code Ive tryed is: x = input(raw_input("Please enter your name: ")) if x==myself: print 'OK' It kinda works - I can get to the please enter your name bit but then it simply reprints your input as output. Someone please HELP! p.s. Im using Ubuntu Linux 5.10 "Breezy Badger". Dont know if you need that info, but just in case. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
Florian Nykrin, that works! Thanks! p.s. Xavier Morel, you seem to be using Windows, not Linux, and I got the idea of stacking input on a raw_input from the official Python Tutorial. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
>what makes you think that basic Python functions work in radically different ways on different platforms ? Assumption. Im also new to programing, so could do something stupid like think a Windows path is a command/input/etc. (really, ive done things like that before.) Now, im running this on a terminal, but am acctually writing my scripts in a text editor. How can I get a script to do a sum with the editor? e.g. it asks for a sum, then does it etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
http://docs.python.org/tut/node6.html#SECTION00610 -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
Thanks, never knew that, but they are using raw_input as a stack, aren't they? -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
Yes, sorry, didnt realise diffrence between int and input. Since i'm such an idiot at this, any links to sites for people who need an unessicerily gentle learning curve? -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
>parse the expression, extract the operands and the operation, apply the operation to the operands How? Give me some example code, but please keep it simple. >are you trying to code a calculator? Not intending to, just trying to learn Python. Suppose what i'm trying to code is a but like a CLI calculator, but i'm just writing it for my own educational beifits. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
I asked to keep it simple! Anyway, ill try Dive into Python, thanks -- http://mail.python.org/mailman/listinfo/python-list
Small newbie question
How would I do this: Write a program that simply outputs a ramdom (in this case) name of (for this example) a Linux distibution. Heres the code ive tryed: from random import uniform from time import sleep x = 2 while x < 5: x = uniform(1, 5) if x >= 1 <= 1.999: print 'SuSE' elif x >= 2 <= 2.999: print 'Ubuntu' elif x >= 3 <= 3.999: print 'Mandriva' elif x >= 4 <= 4.999: print 'Fedora' sleep(2) It dosnt work: only keep printing SuSE. Please help, Thanks in advance, -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Small newbie question
Great stuff, thanks: -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Location of Python modules
Pretty much self explanatry, where are Python modules stored in Linux? (i.e. in /usr/bin/local, or where?) -- http://mail.python.org/mailman/listinfo/python-list
Re: Location of Python modules
No, not there -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Location of Python modules
Found it in /usr/local/lib/python2.4/site-packages, thanks. Now, how do i convert a .py program into a module? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Location of Python modules
>if it is in the sys.path sys.path, what is this? -- http://mail.python.org/mailman/listinfo/python-list
Another stupid newbie question
How can I make the following code: from random import random def stuff(a, mx): x = 2 while x == 2: x = random() if x == mx: print x else: print 'No luck,', x x = 2 Stop when x == mx? Thanks in advance, -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Another stupid newbie question
Great, thanks all. Now, how come if x == mx: print x break Dosnt work? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Another stupid newbie question
Great, thanks all (the point of x = 2 was that i dont understand exactly what True is on while True:) -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Another stupid newbie question
Ahhh, Thanks -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Another stupid newbie question
"Do yourself a HUGE favour and read this before posting any more questions to comp.lang.python. Trust me, you really will thank us. http://www.catb.org/~esr/faqs/smart-questions.html " I find that webpage highly insulting, and so should you. It is treating you like a small child, who needs to be told everything. If you need more information, just ask. I myself have been on hardware lists/fourms for quite a while now. I never answer questions that go into too much detail, I find it off-putting and insulting - I feel it treats me like some sort of robot, that requires all eventualities to be programed into it to start answering the questions. I just ask politly for more info, if I need it. But questions from people saying 'Please help' etc. is great. They know they are in the wrong, and intend to be humorus. They dont intend to annoy/offend anybody. And really, I dont need to be told how to be polite, thank you. As regards to grammer/spelling, what if sombody is unsure of how to spell something? And did you ever hear of being in a rush? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Converting tuple to String
Is their a command to convert a tuple to string? e.g. xyz = "Hello", "There" print xyz Is their any way of getting print to see xyz as being one string i.e. "Hello There" rather than "Hello" and "There", despite "Hello" and "There" being, in reality, seperate? Thanks in advance, -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting tuple to String
Great, that works thanks -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Starting/launching eric3
Decided to try the eric3 IDE, but I cant figure out how to start it! When I extract the file, all I can see is a ton of files and Python scripts. What script will run the program? Where is it? Please help! -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Starting/launching eric3
OK, now I've managed to get it working, but when I run it the eric3 splash screen pops up, and then it says (in terminal): [EMAIL PROTECTED]:~$ eric3 Traceback (most recent call last): File "/usr/lib/site-python/eric3/eric3.py", line 147, in ? main() File "/usr/lib/site-python/eric3/eric3.py", line 132, in main mw = UserInterface(loc, splash) File "/usr/lib/site-python/eric3/UI/UserInterface.py", line 265, in __init__ self.sbv = SBVviewer(dbs, self.sbvDock, 1) File "/usr/lib/site-python/eric3/UI/SBVviewer.py", line 75, in __init__ self.stackComboBox.sizePolicy().hasHeightForWidth())) TypeError: argument 1 of QSizePolicy() has an invalid type Segmentation fault [EMAIL PROTECTED]:~$ Its not ment to do that... how to make it work right?? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Interfacing with the command line
I know its possible to acsess Python via the command line, but can I do the opposite and acsess the command line via Python? For example, can I write a script that will enter $ firefox on the command line, opening Firefox for me? Thanks in advance, -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Interfacing with the command line
Exactly what I want. Thanks a mill! -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Importing an output from another function
Probably a stupid question, but I'm a newbie and this really pisses me off. Run this script: import random def Func1(): choice = ('A', 'B', 'C') output = random.choice(choice) def Func2(): print output Func1() Func2() And: an error message.. It says: Traceback (most recent call last): File "ptls-demo.py", line 11, in ? Func2() File "how -the-hell-do-i-fix-this.py", line 8, in Func2 print output NameError: global name 'output' is not defined Obviosly, I need to import the variable 'output' from Func1() into Func2(), but how? Thanks in advance, -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing an output from another function
Great, thanks -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing an output from another function
Now what do I do if Func1() has multiple outputs and Func2() requires them all to give its own output, as follows: import random def Func1(): choice = ('A', 'B', 'C') output = random.choice(choice) output2 = random.choice(choice) return output return output2 def Func2(item1, item2): print item1, item2 output1 = Func1() Func2(output1) Thanks in advance, -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing an output from another function
"Try this (I think its called "argument expansion", but I really don't know what its called, so I can't point you to docs):" This works, thanks. But how acn I get rid of the ugly surrounding brackets and commas? e.g. If the scripts overall output was (('B', 'C'),), how to change it to just B C? -- http://mail.python.org/mailman/listinfo/python-list
Getting a loop to activate a loop above it
The following code will not work for me: x = 1 while x == 1: print 'hello' x = input('What is x now?: ') while x == 2: print 'hello again' x == input('What is x now?: ') The second loop dose not seem to be able to activate the loop above it Proof from my command line: $ python program-that-dose-not-work.py hello What is x now?: 2 hello again What is x now?: 1 hello again What is x now?: So, now I ask you: how do I make it work? Thanks in advance, -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Working with decimal points
How come: sum = 1/4 print sum returns 0? 1/4=0.25, not 0. How do I fix this? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with decimal points
That dosnt work either: sum = 0.1+1/4 print sum Just returns 0.1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with decimal points
Fredrik Lundh's way works: thank a million! -- http://mail.python.org/mailman/listinfo/python-list