[Tutor] Tkinter's Label

2011-02-16 Thread Emeka
Hello All,


I have the following;
root = Tk()
label = Label(root , text = "pure")
in order to change "text" , I could do the this

label[text] = "pool"

I do know that there is something like this..

label.config(text = "pool")

Which one should I use?


Regards,
Emeka
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Creating xml documents

2011-02-16 Thread allan oware
Alright,
Am stuck with xml.dom.minidom, but is there correct usage for *Node.prettyxml()
*resulting in less junky newlines and spaces ?

i.e *from*


   
28.4258363792
   
   
-6.13557141177
   
   
46.1374243603
   
   
6.41013674147
   
  

*to*
*
*

28.477417
-4.936117
47.341236
5.267412



Regards,
Allan.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Creating xml documents

2011-02-16 Thread Stefan Behnel

allan oware, 16.02.2011 09:20:

Alright,
Am stuck with xml.dom.minidom


Interesting. Why would that be the case?



, but is there correct usage for *Node.prettyxml()
*resulting in less junky newlines and spaces ?

i.e *from*



 28.4258363792


 -6.13557141177


 46.1374243603


 6.41013674147

   

*to*
*
*

 28.477417
 -4.936117
 47.341236
 5.267412



See my reply to your original question: use ElementTree.

Stefan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Accessing query results html frame :The solution

2011-02-16 Thread Karim

On 02/16/2011 08:40 AM, Karim wrote:

On 02/14/2011 01:41 PM, Karim wrote:


Hello,

As I get no response from the tutor python list, I am continuing to 
investigate my problem.


In fact the issue is that there are 2 forms in the interactive page 
and my request does nothing
instead I get the interactive page not the submission I asked (query 
results). The 2 forms are:


   1. 
   2. 

And the parameters for each are:

1)




 
 
 
 
ONCLICK="oncreate()"> 





2)





And I recall my data of the progam below:

data = {
   'init' : "",
   'LastForm': "SavedQuery",
   'prompted': "yes",
   'class': "Development",
   'personalQuery': "DKPV",
   'REMOTE_USER': username,
   'QS': "  -p DKPVALIDATION_PLUGIN \(Class 'isequal' 
"Development" \)",

   'use_field_defs':"false",
   'QueryName': "DKPV",
   'QueryType': "personal",
   'ACTION': "Query"
   }

So the question is how could I specify the correct FORM submission 
and how could I chose the correct action because
there are several TYPE='submit' and I am only interested by this one 
VALUE="Query"?


Regards
Karim

On 02/11/2011 08:51 AM, Karim wrote:


Hello,

In fact as found in the net:

"The concept of browser frames is completely outside the scope of 
HTTP. However, browser frames are defined in HTML, and so is the 
target property on form elements: 
This will make the form submit to the _top frame, which means "use the full browser window" " That means that my post form: ENCTYPE="application/x-www-form-urlencoded" TARGET="rightframe"> has a target property to make the submit to the 'rightframe'. Any ideas how I can modified the code (I think the request data or whatever) below to access without knowing the temporary html file name generically. Regards Karim On 02/10/2011 07:12 PM, Karim wrote: Hello All, I get from Steven an very useful link (void space) for http authentication. I added some codes to be able to POST FORM a query as I do it by clicking a query button to get a list of bug Id on a server. The problem is I get a html page which refers 2 frames. And I am interesting in one particular frame namely for example, http://{server}:{port}/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server, port=port). But this pages is created every times in a tmp directory each time with a different name. 1) How can I get the name of this page because with python the page resulting of my query is not mentionned (hidden like)? Interactively there are 3 frames but only this one is of interest for me. But no name of this page is visible in the main html page. Is there a method to get all the nested frames locations? 2) I can see this page interactively when I click on a submit query button. Do I need to add 'ACTION': "Query" in the query dictionnary to simulate a click for submission (type="submit" button) ? 3) Interactively I see that cgi arg NextForm is empty so I let it like that in my query and LastForm was set to "SavedQuery". I put the same value in my python code. Is this ok? import urllib import urllib2 server='dummy.com' port='8081' username = 'karim.liateni' password = 'dummy_pass' theurl = 'http://{server}:{port}/ddts/ddts_main'.format(server=server, port=port) #theurl = 'http://{server}:{port}:8081/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server, port=port) #MEMO: #ENCTYPE="application/x-www-form-urlencoded" TARGET="rightframe"> data = { 'NextForm': "", 'LastForm': "SavedQuery", 'prompted': "yes", 'class': "Development", 'personalQuery': "DKPV", 'REMOTE_USER': username, 'QS': " -p DKPVALIDATION_PLUGIN \(Class 'isequal' "Development" \)", 'use_field_defs':"false", 'QueryName': "DKPV", 'QueryType': "personal", 'ACTION': "Query" } query = urllib.urlencode(data) request = urllib2.Request(theurl, query) passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, theurl, username, password) authhandler = urllib2.HTTPBasicAuthHandler(passman) opener = urllib2.build_opener(authhandler) urllib2.install_opener(opener) pagehandle = urllib2.urlopen(request) print(pagehandle.read()) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor The solution to handle multiple post forms in a same web page and to submit a given one programmatically is to use this very must have module ClientForm from "http://wwwsearch.sourceforge.net/ClientForm"; and maintained by John J.Lee Example from this module: response = urllib2.urlopen("http://wwwsearch.sourceforge.net/ClientForm/example.htm

Re: [Tutor] Tkinter's Label

2011-02-16 Thread Alan Gauld


"Emeka"  wrote


in order to change "text" , I could do the this

label[text] = "pool"

I do know that there is something like this..

label.configure(text = "pool")


For singlealue changes it's largely a matter of taste 
but I personally use the dictionary form for a single 
value change and configure() where I am changing 
multiple values at the same time. (Otherwise I'd 
need to have multiple lines changing one value each...)


Thus, if the new label were very long and you wanted 
to change the width of the control to accomodate it 
you could do


label.configure(text='a very long message indeed', width=50)

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter's Label

2011-02-16 Thread Emeka
Alan,

Thanks so much.

Is the below the standard way of checking the content of Label in "if"
statement?

 root = Tk()
label = Label(root , text = "pure")


if label["pure"] == "pure":


Regards,
Emeka

On Wed, Feb 16, 2011 at 10:13 AM, Alan Gauld wrote:

>
> "Emeka"  wrote
>
>  in order to change "text" , I could do the this
>>
>> label[text] = "pool"
>>
>> I do know that there is something like this..
>>
>> label.configure(text = "pool")
>>
>
> For singlealue changes it's largely a matter of taste but I personally use
> the dictionary form for a single value change and configure() where I am
> changing multiple values at the same time. (Otherwise I'd need to have
> multiple lines changing one value each...)
>
> Thus, if the new label were very long and you wanted to change the width of
> the control to accomodate it you could do
>
> label.configure(text='a very long message indeed', width=50)
>
> HTH,
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
*Satajanus  Nig. Ltd


*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python GUI Tkinter Button arrangement

2011-02-16 Thread Ganesh Kumar
Hi..

I am new to python , i have creating one application user
agreement..using Tkinter, The Content

of the agreement will reading one file...Agree button will click means
enable next button. And activate script,

Quit button for exit the program,, Dis agree means one warning message
will show up..

all are working but one buttons are top of the screen.  i want button
in bottom of the frame plz. help me..

this my source code


Source Code

http://pastebin.com/Lm5teAtS

Thanks in Advance
-Ganesh.





-- 
Did I learn something today? If not, I wasted it.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python GUI Tkinter Button arrangement

2011-02-16 Thread Ahmed AL-Masri

I suggest to use boa constructor if you are new learning.
just google it. very easy tool to create your interface

--
From: "Ganesh Kumar" 
Sent: Wednesday, February 16, 2011 6:43 PM
To: 
Subject: [Tutor] Python GUI Tkinter Button arrangement


Hi..

I am new to python , i have creating one application user
agreement..using Tkinter, The Content

of the agreement will reading one file...Agree button will click means
enable next button. And activate script,

Quit button for exit the program,, Dis agree means one warning message
will show up..

all are working but one buttons are top of the screen.  i want button
in bottom of the frame plz. help me..

this my source code


Source Code

http://pastebin.com/Lm5teAtS

Thanks in Advance
-Ganesh.





--
Did I learn something today? If not, I wasted it.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python3 Tutorial question about a[:] = []

2011-02-16 Thread Richard D. Moores
from  :

>>> # Clear the list: replace all items with an empty list
>>> a[:] = []
>>> a
[]

I've been using
>>> a = []
>>> a
[]

What's the difference?

Thanks,

Dick Moores
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python3 Tutorial question about a[:] = []

2011-02-16 Thread Brett Ritter
On Wed, Feb 16, 2011 at 12:39 PM, Richard D. Moores  wrote:
> from  :
>
 # Clear the list: replace all items with an empty list
 a[:] = []
 a
> []
>
> I've been using
 a = []
 a
> []
>
> What's the difference?

a = []

This sets the variable "a" to refer to a new list

a[:] = []

This replaces the existing content of a with empty contents.

Check out this example in interactive mode

>>> a = [1,2,3]
>>> b = a
>>> a = []
>>> print a
[]
>>> print b
[1, 2, 3]


Versus:

>>> a = [1,2,3]
>>> b = a
>>> a[:] = []
>>> print a
[]
>>> print b
[]


-- 
Brett Ritter / SwiftOne
swift...@swiftone.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python3 Tutorial question about a[:] = []

2011-02-16 Thread Richard D. Moores
On Wed, Feb 16, 2011 at 09:50, Brett Ritter  wrote:
> On Wed, Feb 16, 2011 at 12:39 PM, Richard D. Moores  
> wrote:
>> from  :
>>
> # Clear the list: replace all items with an empty list
> a[:] = []
> a
>> []
>>
>> I've been using
> a = []
> a
>> []
>>
>> What's the difference?
>
> a = []
>
> This sets the variable "a" to refer to a new list
>
> a[:] = []
>
> This replaces the existing content of a with empty contents.
>
> Check out this example in interactive mode
>
 a = [1,2,3]
 b = a
 a = []
 print a
> []
 print b
> [1, 2, 3]
>
>
> Versus:
>
 a = [1,2,3]
 b = a
 a[:] = []
 print a
> []
 print b
> []

Ah, got it!

Thanks very much.

Dick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter's Label

2011-02-16 Thread Alan Gauld


"Emeka"  wrote

Is the below the standard way of checking the content of Label in 
"if"

statement?

root = Tk()
label = Label(root , text = "pure")

if label["pure"] == "pure":


Almost, but the index should be 'text':

if label["text"] == "pure":

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python GUI Tkinter Button arrangement

2011-02-16 Thread Alan Gauld


"Ganesh Kumar"  wrote


I am new to python , i have creating one application user
agreement..using Tkinter, The Content
of the agreement will reading one file...Agree button will click 
means

enable next button. And activate script,


I'm assuming by User Agreement you mean User Interface?
Maybe some translation software giving strange results?


all are working but one buttons are top of the screen.
i want button in bottom of the frame plz. help me..


It would help if you were a bit more explicit.
Which button is in the wrong place?


this my source code
http://pastebin.com/Lm5teAtS


There are lots of strange things here.
Can I suggest you keep it as simple as possible to start with.
And you should certainly not mix GUI tookits. You have
Tkinter, wx and GTk all included here. If you use Tkinter stick
with that.

Also there is no real need for ttk here yet - once you get
it working you can add some ttk to make it look pretty
but for now I'd stick with plain old Tkinter. (In fact I'd do
the same with PMW, but it does at least give you the
scrolling text box...)

I'm not sure what you think you are doing with the
sys.path line:

sys.path[:0] = ['../../..']

but I strongly suspect its not what you want!

Also it will help if you give your widgets meaningful names.
For example:

widget = Tkinter.Button(self1, text='Next',
   command = lambda b='dhana': 
buttonPress(b) )


why not call it nextButton instead of widget. (personally I just
add one or two letters so here it would be a b for Button
and the name would be: bNext) It makes the code much
easier to understand. You do it for the other buttons, why
not that one?

Also its usually better to keep all the widget construction in a
single place. You have widgets being constructed in 2 different
functions: init and initUI.

I have no idea what defaultKey() is doing. It defines a function
internally which is never used then calls  the main Tk() function
(I assume tk() is a mistake?) But Tk() should only be called once
in an app.

I think the line

if a1 == 1:

should be indented.

Finally, it's slightly unusual in a Tkinter app to define the
event handler functions inside the GUI building function.
It will work but it does mean those evenmt handlers are
invisible to the rest of the app which might limit your
flexibility to reuse them later

All in all it seems like a lot of complexity for what should
be a very simple application. Of course you may be
intending to change the structure to include much more
complex handler functions later. But as it stands it seems
complex for what it does.
.
HTH
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Working with some sort of Timer

2011-02-16 Thread Ryan Strunk
Hello everyone,

I'm a first-time poster and--in fact--first time programmer, so a lot of
this is new to me. I hope to learn a lot about programming from this list,
and I hope you all won't be shy about such feedback as "you're top-posting
again, silly newbie."

I am currently in the midst of producing an audio-only boxing game similar
to Nintendo's Mike Tyson's Punch-Out!!, and I'm running into difficulty when
it comes to working with timed events.

I have begun developing a round class whose job it is to keep an eye on the
clock and the match as a whole, checking for things like how long a fighter
has been lying on the canvas. The relevant code currently looks like this:

def heartbeat(self):
   if self.round_clock_counter > self.round_clock_max:
   #todo, call end_round
   return
   if global_vars.player.fatigue < 100:
   global_vars.player.fatigue += 1
   self.round_clock = delay(1, heartbeat)

(My delay function simply encompasses calling a Timer and starting it.)

I am hoping to use the above-referenced self.round_clock as a measuring
stick to call various punching methods which I programmed into an Opponent
class. For example: at 1 minute, 30 seconds, perform maneuver x. It strikes
me that using threading.Timer to set up all of the possible maneuvers would
be an inelegant solution to the problem, but I'm not certain which other
modules/functions I could use to better carry this out.

My first question, then, pertains to the above implementation of a round
clock. I know that this code can work, and it has the additional benefit of
eventually keeping the round alive even when a fighter is being counted
after the bell rings. At the same time, however, the code carries the burden
of being infinitely recursive without the proper checks in place.
Nevertheless, would the code generally be considered acceptable, or is there
a more elegant solution I should use?

Second, I would welcome any suggestions anyone has as to how I might time
events within a round. Even pointers to specific modules or sections of the
Python documentation would be greatly appreciated.

Thank you all for any help you can provide, and I look forward to learning
and growing with everyone.

Best,
Ryan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor