mkieverpy | 3 Dec 13:20 2007
Picon

Re: General Doubt about tkinter windows...


Hi José,

>I am trying to develop a simple application in python (I am very newby), but
>I have some general doubts… my main window is Tk(), I am using grid manager,
>and when in the application user changes the view, what I do is take a frame
>out of the grid and put another one (and sometimes there are position
>changes of other remaining frames :-S). My doubt is how can I change the
>window?? Because if I use Toplevel window, main window remains under it, and
>user can also continue changing it, what I don’t want, I just want one
>active window in every moment. Could you give me some hints of how doing it?

please state your problem more clearly.
Also: Try to ask one question at a time.

At the moment I can only guess:
Is your problem about modal / non-modal dialogs
like in a 'file-open'- or 'colour-chooser'-dialog?

Regards,
Matthias Kievernagel
(mkiever/at/web/dot/de)
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Jose Ignacio Gisbert | 5 Dec 08:36 2007

First, sorry for sending this mail to this list, I know this is off-topic, but xmpppy-devel mailing list is out of work L  If someone uses xmpppy, please try to answer me, or at least give me a more adequate mailing list, please. Thank you.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 Hi all,

 

I am a newby in xmppy, and I want to make a very simple messaging jabber client. As I read from different tutorials, it seems very easy, in fact, I can send messages to other jabber clients from my “poor” application, but the problem appears when I try to receive messages. I do more or less what Sebastian Moors explains in his “xmpppy: a practical guide”, i.e (code fragment):

 

def StepOn(conn):

    try:

        conn.Process(1)

    except KeyboardInterrupt:

        return 0

    return 1

 

def GoOn(conn):

    while StepOn(conn):

        pass

cl=xmpp.Client(jid.getDomain(),debug=[])

cl.connect()

cl.auth(jid.getNode(),jidparams['password'])

cl.sendInitPresence()

cl.RegisterHandler('message',messageCB)

cl.RegisterHandler('presence',presenceCB)

 

GoOn(cl)

 

 

But when my application enters in GoOn loop, it completely freezes (I have to shut down it by force). Anyone knows why or knows another solution for receiving messages?, I’m using Windows but I don’t think it is the problem.  

 

Thanks in advance, best regards,

_______________________________
José Ignacio Gisbert Sanus

_______________________________________________
PythonCE mailing list
PythonCE <at> python.org
http://mail.python.org/mailman/listinfo/pythonce
Alex Garipidis | 6 Dec 03:07 2007
Picon

How can I edit a string inside a textbox?

//This was originally posted on the python-win32 mailing list where it clearly didn't belong... Sorry for the inconvenience, I hope I did it right this time! Hello everybody, I have a Tkinter Textbox in my application. I want to scan the textbox for a symbol, defined by me as a "mark", and change the word that is inside or next to that symbol. This is what i mean: If a user types this to the textbox: "Hello <at> everybody, how are you doing?" I want to scan this string for the " <at> " character (or something else) and edit the word next to it (or "inside" it, e.g. " <at> everybody <at> "), "everybody" in this case, and make it have a color for example or make it underlined. I suspect that the answer is in the tag methods of Textbox but so far I haven't found an answer yet. Maybe I'm looking in the wrong direction :) Thank you all
Get news, entertainment and everything you care about at Live.com. Check it out!
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Fredrik Lundh | 6 Dec 12:27 2007

Re: How can I edit a string inside a textbox?

Alex Garipidis wrote:

> I have a Tkinter Textbox in my application. I want to scan the
 > textbox for a symbol, defined by me as a "mark", and
 > change the word that is inside or next to that symbol.
>  
> This is what i mean:
>  
> If a user types this to the textbox:
>  
> "Hello  <at> everybody, how are you doing?"
>  
> I want to scan this string for the " <at> " character (or something
 > else) and edit the word next to it (or "inside" it, e.g.
 > " <at> everybody <at> "), "everybody" in this case, and make it have
 > a color for example or make it underlined.

to find things in a text widget, use the "search" method:

    pos = text.search(string, start)

where "string" is the string you want to search for, and start is the 
starting position (e.g. 1.0 or INSERT).

to search for things that match " <at> word", where "word" is an arbitrary 
string of letters or digits, you can use a regular expression, e.g.

    pos = text.search(" <at> \w+", 1.0, regexp=True)

search only returns where the match begins; to find the end of " <at> word", 
you can search from the given position to the first thing that isn't a 
word character:

    end = text.search("\W", pos + " 1 char", regexp=True)

to change the appearance of a block of text, register the style using 
tag_config, and then use tag_add to apply the style tag to the block, e.g.:

    # do this when you create the widget
    text.tag_config("mystyle", foreground="red")

    # do this to apply this style to a range of text
    text.tag_add("mystyle", pos, end)

hope this helps!

</F>
Alex Garipidis | 6 Dec 17:37 2007
Picon

How can I edit a string inside a textbox?

> to find things in a text widget, use the "search" method:
>
> pos = text.search(string, start)
>
> where "string" is the string you want to search for, and start is the
> starting position (e.g. 1.0 or INSERT).
>
> to search for things that match " <at> word", where "word" is an arbitrary
> string of letters or digits, you can use a regular expression, e.g.
>
> pos = text.search(" <at> \w+", 1.0, regexp=True)
>
> search only returns where the match begins; to find the end of " <at> word",
> you can search from the given position to the first thing that isn't a
> word character:
>
> end = text.search("\W", pos + " 1 char", regexp=True)
>
> to change the appearance of a block of text, register the style using
> tag_config, and then use tag_add to apply the style tag to the block, e.g.:
>
> # do this when you create the widget
> text.tag_config("mystyle", foreground="red")
>
> # do this to apply this style to a range of text
> text.tag_add("mystyle", pos, end)
>
> hope this helps!
>
> </F>
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss <at> python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
 
 
Hello Fredric,
 
Thank you for your answer. I am experiencing some problems with the code you suggested. The
 
end = text.search("\W", pos + " 1 char", regexp=True)

gives me this as a result: TclError: bad text index " 1 char". I tried some other options for the " 1 char"
part but the result was the same. Any ideas? I am using Windows XP and Python 2.5.
 
Thanks again for the answer,
 
Alex

Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Fredrik Lundh | 6 Dec 22:42 2007

Re: How can I edit a string inside a textbox?

Alex Garipidis wrote:

> Thank you for your answer. I am experiencing some problems with the code 
> you suggested. The
>  
> end = text.search("\W", pos + " 1 char", regexp=True)
> 
> gives me this as a result: TclError: bad text index " 1 char".

oops, transcription error.  try:

     end = text.search("\W", pos + " + 1c", regexp=True)

or just

     end = text.search("\W", pos + "+1c", regexp=True)

</F>
Bob Greschke | 7 Dec 02:41 2007

Using floats in canvas X,Ys

If someone knows this off the top of their head...

If I plot a line or a rectangle or something (Canvas.create_???) and  
pass floats for the X's and Y's where will the items actually be  
plotted?

Like if I pass an X of 654.2 and one of 654.7 what pixel will actually  
be used?  654 and 655, or both 654, or both 655?

I'm too weary from trying to get a graphing routine that the user can  
click on and zoom in on a portion of a graph to write any more code to  
figure it out! :)  Come to think of it I'm not even sure how I would  
do it.

Thanks a bunch!

Bob
CarlG | 9 Dec 20:47 2007
Picon

Canvas margins?


I am just starting out with Tkinter, but I am sort of a perfectionist...

I am not quite sure how things work exactly with sizes and positions, but
I've run into something to which I see no apparent solution..

I create a window, and give that a background-color and a width and height.
This works fine, but when I add a canvas to the window, this canvas seems to
have a margin of several pixels on all sides, thus making the window wider
and higher. Can this be removed in any way? Has it got to do with an option
I a missing, or with the anchoring or positioning of the canvas?

Any help would be appreciated,

Carl
--

-- 
View this message in context: http://www.nabble.com/Canvas-margins--tp14242512p14242512.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
CarlG | 9 Dec 22:36 2007
Picon

Re: Canvas margins?


I thought I'd paste the code I use:

root = Tk()
tk_bg = "#%02x%02x%02x" % (255, 255, 224) #beige background

root.config(bg=tk_bg, width=300, height=500)

canvas = Canvas(root,width=300, height=500,bg=tk_bg)

If I don't add the canvas, then the window is actually 300 by 500 and has
the background color. With the canvas, the canvas is that size, and
stretches the window a bit by having white borders/margins...
--

-- 
View this message in context: http://www.nabble.com/Canvas-margins--tp14242512p14243575.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
Bob Greschke | 10 Dec 01:19 2007

Re: Canvas margins?

Set the bd to 0: Canvas(Frm, width = x, height = ... bd = 0)

Most, if not all, systems add a border (like a width of 2 or so  
pixels) to the Canvas and the pixel counts get thrown off by that  
amount when you are trying to figure out the size of the Canvas and/or  
where to put things on the Canvas.  If you need a border to make  
things look good (like a sunken border around a graphing area) make a  
sub-Frame of your root window and set its border width to 2 or  
whatever, relief to SUNKEN, and then stick your canvas on to it.

Bob

On 2007-12-09, at 14:36, CarlG wrote:

>
> I thought I'd paste the code I use:
>
> root = Tk()
> tk_bg = "#%02x%02x%02x" % (255, 255, 224) #beige background
>
> root.config(bg=tk_bg, width=300, height=500)
>
> canvas = Canvas(root,width=300, height=500,bg=tk_bg)
>
> If I don't add the canvas, then the window is actually 300 by 500  
> and has
> the background color. With the canvas, the canvas is that size, and
> stretches the window a bit by having white borders/margins...
> -- 
> View this message in context: http://www.nabble.com/Canvas-margins--tp14242512p14243575.html
> Sent from the Python - tkinter-discuss mailing list archive at  
> Nabble.com.
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss <at> python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>

Gmane