Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 22nd, 2008, 5:04 PM   #1
Adam.K
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 Adam.K is on a distinguished road
I am looking for

I have a mead asimple text editor yet cannot find a "font chooser" to incorperate. basically user clicks options - font chooses a font, size and what not and it changes the font either from there on out or if its highlighted.

any help?


note this is all in tkinter not tcl but strickly tkinter
Adam.K is offline   Reply With Quote
Old Apr 22nd, 2008, 5:14 PM   #2
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,629
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
Re: I am looking for

http://tkinter.unpy.net/wiki/FontChooser

Is that what you are looking for?
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Apr 22nd, 2008, 5:18 PM   #3
Adam.K
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 Adam.K is on a distinguished road
Re: I am looking for

Thats the same code i used but heres the issue:

When i state in the menue the command self.font and then go,

def font (self):
import font

*note the following the code you provided me has two things done to it, one it is saved as a file font.py two the last line:

if __name__ == '__main__':

is deleted.

so when in the text application the user clicks options font it willopen although i cannot change the font, i cant change the size or bold ctra the text, once the dialog window is closed the application wont call font.py again. unless i go and shut down the text application and restart it (if that makes any sense (I can send you all the code to show what I mean))

although running font.py on its own allows me to change text, this and that no problems.

question?

how do i implement this code into my project (in a way) so that it allows the user to change the font of the text, size and what not?
Adam.K is offline   Reply With Quote
Old Apr 22nd, 2008, 7:18 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,827
Rep Power: 5 Sane will become famous soon enough
Re: I am looking for

The point of having a script like this is so that you can import it, and call its functions.

At the bottom of the script, there is an example of how to call it.

   root = Tix.Tk( )
   font = askChooseFont( root )

   if font:
      print font

You want to replicate this behaviour in your original program. To do this, save this file as a script called fontchooser.py. And then add the following lines to your original program:

import fontchooser
import Tix

...

        root = Tix.Tk( )
        font = fontchooser.askChooseFont( root )

Now that you have the user's selection stored in the font variable, you can change the font via the appropriate functions in Tkinter.

If you already have a Tix.Tk instance running, you can pass that through as the "root" variable instead.
Sane is offline   Reply With Quote
Old Apr 23rd, 2008, 4:07 PM   #5
Adam.K
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 Adam.K is on a distinguished road
Re: I am looking for

your code works but it wont apply the changes once imported to either the sample text or my text in text pad (text pad is the project i am working on)

Last edited by Adam.K; Apr 23rd, 2008 at 4:18 PM.
Adam.K is offline   Reply With Quote
Old Apr 23rd, 2008, 8:46 PM   #6
Adam.K
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 Adam.K is on a distinguished road
Re: I am looking for

any help?
Adam.K is offline   Reply With Quote
Old Apr 23rd, 2008, 8:51 PM   #7
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,827
Rep Power: 5 Sane will become famous soon enough
Re: I am looking for

Of course not. You haven't yet changed the font. You've only selected it and stored it as the variable "font".

Now you are supposed to call the necessary function in tkinter. Find the function that changes the font, and pass through the "font" variable. Search the docs to find this function.
Sane is offline   Reply With Quote
Old Apr 24th, 2008, 12:03 PM   #8
Adam.K
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 Adam.K is on a distinguished road
Re: I am looking for

Im going to be blunt here, im a newb at Tkinter, I know the basics, but im not sure what you mewan i do on a methodical level, i understand what your saying but could you show me?
Adam.K is offline   Reply With Quote
Old Apr 25th, 2008, 7:44 PM   #9
Adam.K
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 Adam.K is on a distinguished road
Re: I am looking for

So no one can help me?
I had to input your code you game me for my program to call it under:

def Font(self):
import Font
import Tix

root = Tix.Tk( )
Font = Font.askChooseFont( root )

Thats the only way it would call it with out breaking up the interface.
Adam.K is offline   Reply With Quote
Old Apr 25th, 2008, 10:20 PM   #10
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 640
Rep Power: 4 Jessehk is on a distinguished road
Re: I am looking for

We will help you, but you seem to think that "help[ing] me" is the same as "writing my programs for me".

We can help you by explaining fundamental concepts if they are unclear, by clarifying the directions you should be going in, and by providing resources where you can learn more or read about the topic in question.

In this case, clarifying exactly what is unclear about what you need to do might be helpful to us so that we can help you.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC