Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   I am looking for (http://www.programmingforums.org/showthread.php?t=15681)

Adam.K Apr 22nd, 2008 5:04 PM

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

big_k105 Apr 22nd, 2008 5:14 PM

Re: I am looking for
 
http://tkinter.unpy.net/wiki/FontChooser

Is that what you are looking for?

Adam.K Apr 22nd, 2008 5:18 PM

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?

Sane Apr 22nd, 2008 7:18 PM

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.

Adam.K Apr 23rd, 2008 4:07 PM

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)

Adam.K Apr 23rd, 2008 8:46 PM

Re: I am looking for
 
any help?

Sane Apr 23rd, 2008 8:51 PM

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.

Adam.K Apr 24th, 2008 12:03 PM

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 Apr 25th, 2008 7:44 PM

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.

Jessehk Apr 25th, 2008 10:20 PM

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.


All times are GMT -5. The time now is 9:23 PM.

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