![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2008
Posts: 11
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
PFO Founder
![]() ![]() |
Re: I am 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. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2008
Posts: 11
Rep Power: 0
![]() |
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? |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
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 fontYou 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. |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Apr 2008
Posts: 11
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Apr 2008
Posts: 11
Rep Power: 0
![]() |
Re: I am looking for
any help?
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() |
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. |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Apr 2008
Posts: 11
Rep Power: 0
![]() |
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?
|
|
|
|
|
|
#9 |
|
Newbie
Join Date: Apr 2008
Posts: 11
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#10 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 641
Rep Power: 4
![]() |
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! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|