473,614 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing font style/size for overall wx.python GUI look

46 New Member
Hey guys

I have had a bit of a hunt around on google to try find out how to change the overall default font style/size for a wx.python app - but not had any luck.

Does anyone have any idea if it is possible?

All I really want to do is make the wx.StaticText, wx.CheckBox, wx.TextCtrl & wx.Button fonts smaller in my GUI app

Thanks if anyone can give me some pointers!

Cheers

Adam
Jul 11 '07 #1
4 14084
bartonc
6,596 Recognized Expert Expert
Hey guys

I have had a bit of a hunt around on google to try find out how to change the overall default font style/size for a wx.python app - but not had any luck.

Does anyone have any idea if it is possible?

All I really want to do is make the wx.StaticText, wx.CheckBox, wx.TextCtrl & wx.Button fonts smaller in my GUI app

Thanks if anyone can give me some pointers!

Cheers

Adam
One word: inheritance! Set the font size for a panel and all the widgets on that panel get that font size by default. Same thing with any parent of any widget. Since the app is not a window, nobody inherits attributes from it.

I'm pretty sure, but I'll double check that.
Jul 11 '07 #2
bartonc
6,596 Recognized Expert Expert
One word: inheritance! Set the font size for a panel and all the widgets on that panel get that font size by default. Same thing with any parent of any widget. Since the app is not a window, nobody inherits attributes from it.

I'm pretty sure, but I'll double check that.
wxWindow is the lowes object that I could find that has a font attribute. The most interesting thing that I stumbled across was this:
wxWindow::Inher itAttributes
void InheritAttribut es()

This function is (or should be, in case of custom controls) called during window creation to intelligently set up the window visual attributes, that is the font and the foreground and background colours.

By "intelligently' ' the following is meant: by default, all windows use their own default attributes. However if some of the parents attributes are explicitly (that is, using SetFont and not SetOwnFont) changed and if the corresponding attribute hadn't been explicitly set for this window itself, then this window takes the same value as used by the parent. In addition, if the window overrides ShouldInheritCo lours to return false, the colours will not be changed no matter what and only the font might.

This rather complicated logic is necessary in order to accommodate the different usage scenarios. The most common one is when all default attributes are used and in this case, nothing should be inherited as in modern GUIs different controls use different fonts (and colours) than their siblings so they can't inherit the same value from the parent. However it was also deemed desirable to allow to simply change the attributes of all children at once by just changing the font or colour of their common parent, hence in this case we do inherit the parents attributes.
Jul 11 '07 #3
ateale
46 New Member
Thanks BartonC !
I had a look and tried to use:
font = wx.Font(10, wx.FONTFAMILY_M ODERN, wx.NORMAL, wx.BOLD)
wx.Window.SetFo nt(self, font)

but it doesn't change anything

I don't think i really understand the wx.window and inheritance thing. I read about inheritance in the doc, but I don't understand how to apply it to my script

i just realised I am using wx.Frame not wx.Window - guess this is the reason?

Any ideas?

Thanks!

Adam
Jul 13 '07 #4
bartonc
6,596 Recognized Expert Expert
Thanks BartonC !
I had a look and tried to use:
panel.SetFont(w x.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

but it doesn't change anything

I don't think i really understand the wx.window and inheritance thing. I read about inheritance in the doc, but I don't understand how to apply it to my script

Any ideas?

Thanks!

Adam
Yep. When you're sticking down your widgets in a frame, you need to watch who the parent is. I'll use a subclass of dialog as an example:
Expand|Select|Wrap|Line Numbers
  1. class SegmentDialog(wx.Dialog):   # The parent of widgets that get self as their parent
  2.     def _init_ctrls(self, prnt):
  3.         # generated method, don't edit
  4.         wx.Dialog.__init__(self, id=wxID_SEGMENTDIALOG, name='SegmentDialog', parent=prnt,
  5.                 pos=wx.Point(8, 8), size=wx.Size(1008, 724), style=wx.DEFAULT_DIALOG_STYLE,
  6.                 title='Station Capture - HETAP Pro 2.0')
  7.         self.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL, False,'MS Shell Dlg 2'))
  8. # the panel would get that font, but gets its own, instead.
  9.  
  10.         self.panel1 = wx.Panel(id=wxID_SEGMENTDIALOGPANEL1, name='panel1', parent=self,   # Here is the panel's parent #
  11.                 pos=wx.Point(0, 0), size=wx.Size(1008, 696), style=wx.TAB_TRAVERSAL)
  12.         self.panel1.SetBackgroundColour(wx.Colour(232, 232, 232))
  13.         self.panel1.SetToolTipString('')
  14.         self.panel1.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, False,'MS Shell Dlg 2'))
  15. # widgets get the panel as the parent
  16.  
  17.         self.staticLine1 = wx.StaticLine(id=wxID_SEGMENTDIALOGSTATICLINE1, name='staticLine1',
  18.                 parent=self.panel1, pos=wx.Point(16, 185), size=wx.Size(795, 3), style=0)
  19. # and, so, get that font
  20.  
  21.     def __init__(self, parent, dbDialog, publisher):
  22.         self._init_ctrls(parent)
Hope that's clear.
Jul 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

131
21618
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately get some good real world examples. Fire away! :) Regards, Peter Foti
0
2939
by: Paul D. Sullivan | last post by:
I've been trying to find out how to increase the font size in the text entry fields in Invision Power Board 1.3 for a while. The part where you enter your post and do the quick reply and all that has a really small font by comparision to the display font in the forum, and I wanted to at least have the same size if possible. After some hours of working the issue, I tested about every relevant entry in the Style Sheet. I found one line...
31
5684
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a calendar, 7 across by whatever needed down, and I manually create it each month - not a big deal. Every day I go in and darken the background color of the current day's cell by changing the appropriate <TD> entry to <TD bgcolor="c63800"> and...
4
3487
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a snippet from my .css file: *************************** body { margin:0; padding:0;
7
2952
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and already formatted as "Shopping" ---Bold "for" -----Regular Now I want to underline whole text by preserving old style i.e. Bold and
15
3844
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px; margin-left: -400px; width: 800px; height: 26px"> <!-- CODE GOES HERE --> </div>
30
4517
by: Takehiko Abe | last post by:
I have a <pelement with <ttinside: ;;; <p>A paragraph contains <tt>tt element</tt>.</p> I would like to set the font-size of the TT to the same as the containing <p>. This does not seem to work: ;;; p {
18
24951
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
4
3315
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
0
8182
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8627
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8579
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8279
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5540
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4127
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1425
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.