473,765 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting font using wx.

28 New Member
I have the following code snippet from a larger program which is working perfectly for making a gui and adding buttons to it:
Expand|Select|Wrap|Line Numbers
  1.  
  2. self.B0 = wx.Button(id=wxID_FRAME2B0, label='Choose Cases', 
  3.          name='B0', parent=self, pos=wx.Point(300, 50), 
  4.          size=wx.Size(400, 50),style=0)
  5. self.B0.Bind(wx.EVT_BUTTON, self.OnB0Button, id=wxID_FRAME2B0)
I have no problems setting up the buttons but am now trying to add a larger font size and different font style to it. I have tried using these to no avail:

font=wx.Font(25 , wx.SWISS, wx.BOLD)
font=wx.SetFont (25, wx.SWISS, wx.BOLD)

The gui keeps crashing everytime i add one of these.
I have multiple buttons and would like one of them to have really big font but the others to have normal font.

Any help will be much appreciated.
Aug 19 '09 #1
7 6805
bvdet
2,851 Recognized Expert Moderator Specialist
What specific error message do you receive? To access a font that is accessible to the underlying system:
Expand|Select|Wrap|Line Numbers
  1. wx.Font(pointSize, family, style, weight)
Try providing a style argument.
Aug 19 '09 #2
fahadqureshi
28 New Member
Okay i added it to the code like so:

Expand|Select|Wrap|Line Numbers
  1. self.B1 = wx.Button(id=wxID_FRAME2B1, label='Ratings/RXB',
  2.            name='B1', parent=self, pos=wx.Point(100, 375), 
  3.            size=wx.Size(90,25), style=0, 
  4.            font=wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL))
  5. self.B1.Bind(wx.EVT_BUTTON, self.OnB1Button, id=wxID_FRAME2B1)
the error i am getting is
TypeError: 'font' is an invalid keyword argument for this function

I think i am referencing it incorrectly. Does it need to be declared within the wx.Button() parameters or is it supposed to be declared outside and then referenced within wx.Button() using some shorter code like font=(font1)?
Aug 19 '09 #3
bvdet
2,851 Recognized Expert Moderator Specialist
Try using the SetFont() button method.
Expand|Select|Wrap|Line Numbers
  1. self.B1.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL))
Aug 19 '09 #4
fahadqureshi
28 New Member
ok i tried that but now i am getting this

AttributeError: 'Frame2' object has no attribute 'B1'

Expand|Select|Wrap|Line Numbers
  1.         self.B1.SetFont(wx.Font(12, wx.SWITSS, wx.NORMAL, wx.NORMAL))
  2.         self.B1 = wx.Button(id=wxID_FRAME2B1, label='Ratings/RXB',
  3.               name='B1', parent=self, pos=wx.Point(100, 375), size=wx.Size(90,25), style=0)
  4.         self.B1.Bind(wx.EVT_BUTTON, self.OnB1Button, id=wxID_FRAME2B1)
is there something specific about placement of the code? does it have to go somewhere specific or can it go anywhere before the button definition like i have it ?
Aug 19 '09 #5
bvdet
2,851 Recognized Expert Moderator Specialist
You have to define self.B1 before you can use method self.B1.SetFont (). Think about it. How can you call a method of an object that does not exist?

-BV
Aug 19 '09 #6
fahadqureshi
28 New Member
AHHHHHHHHHHh i see. Thanks for your help. That was really stupid of me to not see that. Anyways I got it to work it needed to go after the button definition.
Thanks again. :)
Aug 19 '09 #7
bvdet
2,851 Recognized Expert Moderator Specialist
No problem. I am glad I could help. :)

-BV
Aug 19 '09 #8

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

Similar topics

12
3226
by: Jacob Weber | last post by:
Hello. Is it possible to specify the exact space between two lines, measured from the baseline of the top line to the ascenders of the second line? I tried adding the space with padding-bottom, but it adds it below the descenders. So the actual space between lines is larger than I specified. Jacob
9
2563
by: netclectic | last post by:
I'm dynamically adding options to a select list in javascript and i need to be able to set the height of the option, but setting style.height has not effect, I also tried style.pixelHeight but no joy. i'm doing something like this (: var selectControl = document.getElementById('MySelect'); var el = document.createElement('option'); el.value = "some value";
18
2189
by: fleemo17 | last post by:
My organization is developing a set of "standards" for websites built inhouse. The first question that comes to mind is what would be a good standard default size for <p> text? 12 point? Which begs the question, what unit of measurement should we use for specifying font sizes, points or ems? Thanks. -Fleemo
5
27847
by: dixie | last post by:
I want to be able to set the font size and font type for text in a text box on a report using VBA. I wan't to be able to control it from a setting in a table. The problem is that I don't know the syntax for setting either font type or font size for a text box on a report. Does anyone know? Help. Please! dixie
14
4031
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
1
6508
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
3
52250
by: Jason Carlton | last post by:
Is there a way to change the font-family and font-size for each individual option in a select menu? Something along the lines of: <select size="1"> <option style="font-family: Arial; font-size: 8px">One</option> <option style="font-family: Tahoma; font-size: 10px">Two</option> <option style="font-family: Verdana; font-size: 12px">Three</option> </select> I see that I can change the color using style="color: whatever", but
6
1965
by: Steve | last post by:
I have a div with two - three paragrahs in it. Each paragraph has its own inline style tag with its own font size setting. When I set the last paragraph's font size the font sizes for ALL of the paragraphs change. Why? How can I stop it? I.E>
1
1258
by: RGK | last post by:
I'm doing an app with the AUI manager capabilities (using some of the wxPython demo's for help). All is well, except I'm a bit disappointed with the font management. The default font for all the widgets (TextCtrl's, StaticText's etc) are a bit large for my design intent and as I try to adjust that, it appears I have to do a font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT) font.SetPointSize(9)
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10008
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
9959
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
9837
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
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
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.