Re: Dynamically change font size of a TextArea
John Henry <[email protected]> Tue, 21 Jun 2011 09:46:02 -0700
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --===============1504719608406999785== Content-Type: multipart/alternative; boundary="------------010507090101090303070905" This is a multi-part message in MIME format. --------------010507090101090303070905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit You need to post the rsrc file as well. Then others can try running the code on their side. On 6/21/2011 7:23 AM, hwg wrote: > I tried both of the methods below: > > I get the following error: > > Traceback (most recent call last): > File "C:\Python25\lib\site-packages\PythonCard\widget.py", line 408, > in _dispatch > handler(background, aWxEvent) > File > "C:\Users\wsande\Documents\Warren\PythonScripts\PC_slider_text\pc_slider_text.py", > line 11, in on_Slider1_mouseUp > font.SetPointSize(sliderValue) > AttributeError: 'Font' object has no attribute 'SetPointSize' > > Here's the complete code: > > # pc_slider_text.py <http://pc_slider_text.py/> > # try to change the size of text font in a test box using a slider > > from wx import * > from PythonCard import model > class MainWindow(model.Background): > def on_Slider1_mouseUp(self, event): > sliderValue = self.components.Slider1.value > print sliderValue > font = self.components.TextArea1.font > font.SetPointSize(sliderValue) > self.components.TextArea1.SetFont(font) > print self.components.TextArea1.font > > app = model.Application(MainWindow) > app.MainLoop() > > ------------------------------------------------------------------------ > *From:* Lawrence Abbott <[email protected]> > *To:* hwg <[email protected]> > *Sent:* Monday, June 20, 2011 10:37 PM > *Subject:* Re: [Pythoncard-users] Dynamically change font size of > a TextArea > > A slightly cleaner way > > font = self.components.TextArea1.GetFont() > font.SetPointSize(16) > self.components.TextArea1.SetFont(font) > > Cheers, > Lawrie > > On Tue, Jun 21, 2011 at 12:26 PM, Lawrence Abbott > <[email protected] <mailto:[email protected]>> wrote: > > Hi, > > > > self.components.TextArea1.font_size = sliderValue > > > > doesnt work for me > > > > print self.components.TextArea1.font.size > > > > gives a dictionary of font attributes, but I can't get them to > update either > > > > import wx > > > > font_size =16 > > > > font1 = self.components.TextArea1.GetFont() > > font2 = wx.Font(font_size, font1.Family, font1.Style, font1.Weight) > > self.components.TextArea1.SetFont( font2 ) > > > > seems to work > > > > HTH, > > Lawrie > > > > On Mon, Jun 20, 2011 at 2:27 AM, hwg <[email protected] > <mailto:[email protected]>> wrote: > >> I tried: > >> > >> self.components.TextArea1.font_size = sliderValue > >> It doesn't throw an exception, but it doesn't change the font > size, either. > >> Also, oddly, the slider never seems to lose focus. It keeps > sliding back > >> and forth even after the mouse is released and no longer over > the slider. I > >> can't get focus on the TextArea. > >> > >> > >> - hwg > >> > >> > >> ________________________________ > >> From: "[email protected] <mailto:[email protected]>" > <[email protected] <mailto:[email protected]>> > >> To: hwg <[email protected] <mailto:[email protected]>> > >> Cc: "[email protected] > <mailto:[email protected]>" > >> <[email protected] > <mailto:[email protected]>> > >> Sent: Saturday, June 18, 2011 11:45 PM > >> Subject: Re: [Pythoncard-users] Dynamically change font size of > a TextArea > >> > >> font is not a dictionary. It's a class. Try font._size > >> > >> On 6/17/2011 1:23 PM, hwg wrote: > >> > >> from PythonCard import model > >> class MainWindow(model.Background): > >> def on_Slider1_mouseUp(self, event): > >> sliderValue = self.components.Slider1.value > >> self.components.TextArea1.font['size'] = sliderValue > >> > >> app = model.Application(MainWindow) > >> app.MainLoop() > >> > >> -- > >> Kim Cheung > >> > >> > >> > ------------------------------------------------------------------------------ > >> EditLive Enterprise is the world's most technically advanced > content > >> authoring tool. Experience the power of Track Changes, Inline Image > >> Editing and ensure content is compliant with Accessibility > Checking. > >> http://p.sf.net/sfu/ephox-dev2dev > >> _______________________________________________ > >> Pythoncard-users mailing list > >> [email protected] > <mailto:[email protected]> > >> https://lists.sourceforge.net/lists/listinfo/pythoncard-users > >> > >> > > > > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > > > _______________________________________________ > Pythoncard-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/pythoncard-users --------------010507090101090303070905 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> <tt>You need to post the rsrc file as well. Then others can try running the code on their side.</tt><br> <br> On 6/21/2011 7:23 AM, hwg wrote: <blockquote cite="mid:[email protected]" type="cite"> <div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Courier New,courier,monaco,monospace,sans-serif; font-size: 10pt;"> <div>I tried both of the methods below:</div> <div><br> </div> <div>I get the following error:</div> <div style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br> </div> <div><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">Traceback (most recent call last):</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> File "C:\Python25\lib\site-packages\PythonCard\widget.py", line 408, in _dispatch</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">handler(background, aWxEvent)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> File "C:\Users\wsande\Documents\Warren\PythonScripts\PC_slider_text\pc_slider_text.py", line 11, in on_Slider1_mouseUp</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">font.SetPointSize(sliderValue)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">AttributeError: 'Font' object has no attribute 'SetPointSize'</span><br> </div> <div><br> </div> <div>Here's the complete code:</div> <div><br> </div> <div style="font-family: Courier New,courier,monaco,monospace,sans-serif;"># <a moz-do-not-send="true" target="_blank" href="http://pc_slider_text.py/"><span class="yshortcuts" id="lw_1308666021_0">pc_slider_text.py</span></a><br> # try to change the size of text font in a test box using a slider<br> <br> </div> <div><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">from wx import *</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">from PythonCard import model</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">class MainWindow(model.Background):</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> def on_Slider1_mouseUp(self, event):</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> sliderValue = self.components.Slider1.value</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> print sliderValue</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> font = self.components.TextArea1.font</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> font.SetPointSize(sliderValue)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> self.components.TextArea1.SetFont(font)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> print self.components.TextArea1.font</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"></span></div> <div><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br> </span></div> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">a</span><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">pp = model.Application(MainWindow)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">app.MainLoop()</span> <div><br> <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> <div style="font-family: Courier New,courier,monaco,monospace,sans-serif; font-size: 10pt;"> <div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2" face="Arial"> <hr size="1"><b><span style="font-weight: bold;">From:</span></b> Lawrence Abbott <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]"><[email protected]></a><br> <b><span style="font-weight: bold;">To:</span></b> hwg <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]"><[email protected]></a><br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, June 20, 2011 10:37 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Pythoncard-users] Dynamically change font size of a TextArea<br> </font><br> A slightly cleaner way<br> <br> font = self.components.TextArea1.GetFont()<br> font.SetPointSize(16)<br> self.components.TextArea1.SetFont(font)<br> <br> Cheers,<br> Lawrie<br> <br> On Tue, Jun 21, 2011 at 12:26 PM, Lawrence Abbott <<a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>> wrote:<br> > Hi,<br> ><br> > self.components.TextArea1.font_size = sliderValue<br> ><br> > doesnt work for me<br> ><br> > print self.components.TextArea1.font.size<br> ><br> > gives a dictionary of font attributes, but I can't get them to update either<br> ><br> > import wx<br> ><br> > font_size =16<br> ><br> > font1 = self.components.TextArea1.GetFont()<br> > font2 = wx.Font(font_size, font1.Family, font1.Style, font1.Weight)<br> > self.components.TextArea1.SetFont( font2 )<br> ><br> > seems to work<br> ><br> > HTH,<br> > Lawrie<br> ><br> > On Mon, Jun 20, 2011 at 2:27 AM, hwg <<a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>> wrote:<br> >> I tried:<br> >><br> >> self.components.TextArea1.font_size = sliderValue<br> >> It doesn't throw an exception, but it doesn't change the font size, either.<br> >> Also, oddly, the slider never seems to lose focus. It keeps sliding back<br> >> and forth even after the mouse is released and no longer over the slider. I<br> >> can't get focus on the TextArea.<br> >><br> >><br> >> - hwg<br> >><br> >><br> >> ________________________________<br> >> From: "<a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>" <<a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>><br> >> To: hwg <<a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>><br> >> Cc: "<a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>"<br> >> <<a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>><br> >> Sent: Saturday, June 18, 2011 11:45 PM<br> >> Subject: Re: [Pythoncard-users] Dynamically change font size of a TextArea<br> >><br> >> font is not a dictionary. It's a class. Try font._size<br> >><br> >> On 6/17/2011 1:23 PM, hwg wrote:<br> >><br> >> from PythonCard import model<br> >> class MainWindow(model.Background):<br> >> def on_Slider1_mouseUp(self, event):<br> >> sliderValue = self.components.Slider1.value<br> >> self.components.TextArea1.font['size'] = sliderValue<br> >><br> >> app = model.Application(MainWindow)<br> >> app.MainLoop()<br> >><br> >> --<br> >> Kim Cheung<br> >><br> >><br> >> ------------------------------------------------------------------------------<br> >> EditLive Enterprise is the world's most technically advanced content<br> >> authoring tool. Experience the power of Track Changes, Inline Image<br> >> Editing and ensure content is compliant with Accessibility Checking.<br> >> <a class="moz-txt-link-freetext" href="http://p.sf.net/sfu/ephox-dev2dev">http://p.sf.net/sfu/ephox-dev2dev</a><br> >> _______________________________________________<br> >> Pythoncard-users mailing list<br> >> <a moz-do-not-send="true" ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a><br> >> <a moz-do-not-send="true" href="https://lists.sourceforge.net/lists/listinfo/pythoncard-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/pythoncard-users</a><br> >><br> >><br> ><br> <br> <br> </div> </div> </blockquote> </div> </div> <pre wrap=""> <fieldset class="mimeAttachmentHeader"></fieldset> ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. <a class="moz-txt-link-freetext" href="http://p.sf.net/sfu/ephox-dev2dev">http://p.sf.net/sfu/ephox-dev2dev</a></pre> <pre wrap=""> <fieldset class="mimeAttachmentHeader"></fieldset> _______________________________________________ Pythoncard-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/pythoncard-users">https://lists.sourceforge.net/lists/listinfo/pythoncard-users</a> </pre> </blockquote> <br> </body> </html> --------------010507090101090303070905-- --===============1504719608406999785== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev --===============1504719608406999785== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Pythoncard-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pythoncard-users --===============1504719608406999785==--