LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-14-2007, 10:54 AM   #1
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Rep: Reputation: 15
Easy perltk question.


How do I change the window font?
It's like 5 times bigger than everything on my desktop.
Can't find anything describing how to do this.
A good source of examples or documentation would be very helpful.
Thanks.
 
Old 01-15-2007, 12:11 PM   #2
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143

Original Poster
Blog Entries: 8

Rep: Reputation: 15
I found it.
I found some info in the man page.Here is how you do it.

Code:
#!/usr/bin/perl -w
use Tk;
my $mw=new MainWindow;
my $label = $mw->Label(-font=>['helvetica',10],-text => "Some text"); 
$label->pack;
my $messages=$mw->messageBox(-message=>"font",-font=>['times',8]);
MainLoop;
I only found 3 fonts times,helvetica and courier.I'm just learning Tk and perl and so far it's great.
 
Old 01-15-2007, 12:50 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You can also save fonts in the MainWindow object, and refer to them by name. This makes it a little easier to change the appearance of your app at a later date (single point of modification):
Code:
#!/usr/bin/perl -w

use Tk;

my $mw = new MainWindow;
$mw->fontCreate(qw/myfont1 -family roman -size 16/);
$mw->fontCreate(qw/myfont2 -family times -size 20/);

my $label = $mw -> Label(-text=>"Hello World", -font => "myfont1") -> pack();
my $button = $mw -> Button(-text => "Quit", -font => "myfont2", -command => sub { exit });
$button->pack();

MainLoop;
 
Old 01-15-2007, 12:51 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Tk is quite nice for quick ugly GUI apps. Using TCL instead of Perl is also worth a look - TCL crops up in all sorts of places so it's useful to know, and it's very easy to learn.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PerlTK - save console in file Rufus T. Firefly Programming 7 12-13-2006 08:48 PM
PerlTK loose control in loop Atrocity Programming 1 05-10-2005 12:16 PM
PerlTk package juris Mandriva 0 10-26-2004 04:36 AM
set perlTK always-on-top \ topmost plast1cfl00r Programming 0 08-21-2004 02:24 PM
easy question 5amYan *BSD 4 04-25-2002 04:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration