Re: Dynamically change font size of a TextArea
hwg <[email protected]> Tue, 21 Jun 2011 10:43:44 -0700 (PDT)
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
--0-429441989-1308678224=:55592 Content-Type: multipart/alternative; boundary="0-1412455963-1308678224=:55592" --0-1412455963-1308678224=:55592 Content-Type: text/plain; charset=us-ascii Lawrie, That works. Thanks! I still have a weird issue where the Slider doesn't give up focus. I start dragging it, and when I release it (mouseUp), the event handler fires and the font size changes. But I can't enter the TextArea, and the slider still moves around as I move the mouse, even with no mouse buttons pressed. I can't access the TextArea or the Menu, and I can't even close the PythonCard app window without going into the IDE and stopping the script from there. Any idea what's causing this? Complete code is attached. Thanks, hwg ________________________________ From: Lawrence Abbott <[email protected]> To: hwg <[email protected]> Cc: pythoncard-users <[email protected]> Sent: Tue, June 21, 2011 7:45:50 AM Subject: Re: [Pythoncard-users] Dynamically change font size of a TextArea try font = self.components.TextArea1.GetFont() instead of font = self.components.TextArea1.font also you will need to ensure the slider output values are legitimate font sizes also should be no need to import wx with SetPointSize method Cheers, Lawrie On Tue, Jun 21, 2011 at 10:23 PM, hwg <[email protected]> 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 > # 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]> 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]> 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]" <[email protected]> >>> To: hwg <[email protected]> >>> Cc: "[email protected]" >>> <[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] >>> 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 > > --0-1412455963-1308678224=:55592 Content-Type: text/html; charset=us-ascii <html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:Courier New,courier,monaco,monospace,sans-serif;font-size:10pt"><div>Lawrie,<br><br>That works. Thanks!<br><br>I still have a weird issue where the Slider doesn't give up focus. I start dragging it, and when I release it (mouseUp), the event handler fires and the font size changes. But I can't enter the TextArea, and the slider still moves around as I move the mouse, even with no mouse buttons pressed. I can't access the TextArea or the Menu, and I can't even close the PythonCard app window without going into the IDE and stopping the script from there.<br><br>Any idea what's causing this?<br><br>Complete code is attached.<br><br><br>Thanks,<br>hwg<br><br></div>< div style="font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Lawrence Abbott <[email protected]><br><b><span style="font-weight: bold;">To:</span></b> hwg <[email protected]><br><b><span style="font-weight: bold;">Cc:</span></b> pythoncard-users <[email protected]><br><b><span style="font-weight: bold;">Sent:</span></b> Tue, June 21, 2011 7:45:50 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Pythoncard-users] Dynamically change font size of a TextArea<br></font><br> try<br>font = self.components.TextArea1.GetFont()<br><br>instead of<br>font = self.components.TextArea1.font<br><br>also you will need to ensure the slider output values are legitimate font sizes<br>also should be no need to import wx with SetPointSize method<br><br>Cheers,<br>Lawrie<br><br><br>On Tue, Jun 21, 2011 at 10:23 PM, hwg <<a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>> wrote:<br>> I tried both of the methods below:<br>> I get the following error:<br>> Traceback (most recent call last):<br>> File "C:\Python25\lib\site-packages\PythonCard\widget.py", line 408, in<br>> _dispatch<br>> handler(background, aWxEvent)<br>> File<br>> "C:\Users\wsande\Documents\Warren\PythonScripts\PC_slider_text\pc_slider _text.py",<br>> line 11, in on_Slider1_mouseUp<br>> font.SetPointSize(sliderValue)<br>> AttributeError: 'Font' object has no attribute 'SetPointSize'<br>><br>> Here's the complete code:<br>> # <a target="_blank" href="http://pc_slider_text.py">pc_slider_text.py</a><br>> # try to change the size of text font in a test box using a slider<br>><br>> from wx import *<br>> from PythonCard import model<br>> class MainWindow(model.Background):<br>> def on_Slider1_mouseUp(self, event):<br>> sliderValue = self.components.Slider1.value<br>> print sliderValue<br>> font = self.components.TextArea1.font<br>> font.SetPointSize(sliderValue)<br>> self.components.TextArea1.SetFont(font) <br>> print self.components.TextArea1.font<br>><br>> app = model.Application(MainWindow)<br>> app.MainLoop()<br>><br>> ________________________________<br>> From: Lawrence Abbott <<a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>><br>> To: hwg <<a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>><br>> Sent: Monday, June 20, 2011 10:37 PM<br>> Subject: Re: [Pythoncard-users] Dynamically change font size of a TextArea<br>><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 &l t;<a 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<br>>> 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 ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>> wrote:<b r>>>> 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,<br>>>> 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<br>>>> slider. I<br>>>> can't get focus on the TextArea.<br>>>><br>>>><br>>>> - hwg<br>>>><br>>>><br>>>> ________________________________<br>>>> From: "<a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>" <<a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>><br>>>> To: hwg <<a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>><br>>>> Cc: "<a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a>"<br>>>> <<a 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<br>>>> 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>>>& gt; 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>>>> ------------------------------------------------------------------------------<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><span>>>> <a target="_blank" href="http://p.sf.net/sfu/ephox-dev2dev">http://p.sf.net/sfu/ephox-dev2dev</a></span><br>>>> ___ ____________________________________________<br>>>> Pythoncard-users mailing list<br>>>> <a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a><br>>>> <a 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>><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 href="http://p.sf.net/sfu/ephox-dev2dev" target="_blank">http://p.sf.net/sfu/ephox-dev2dev</a><br>> __________________________________ _____________<br>> Pythoncard-users mailing list<br>> <a ymailto="mailto:[email protected]" href="mailto:[email protected]">[email protected]</a><br>> <a href="https://lists.sourceforge.net/lists/listinfo/pythoncard-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/pythoncard-users</a><br>><br>><br></div></div> </div></body></html> --0-1412455963-1308678224=:55592-- --0-429441989-1308678224=:55592 Content-Type: application/octet-stream; name="pc_slider_text.py" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pc_slider_text.py" IyBwY19zbGlkZXJfdGV4dC5weQojIHRyeSB0byBjaGFuZ2UgdGhlIHNpemUg b2YgdGV4dCBmb250IGluIGEgdGV4dCBib3ggdXNpbmcgYSBzbGlkZXIKCmZy b20gd3ggaW1wb3J0ICoKZnJvbSBQeXRob25DYXJkIGltcG9ydCBtb2RlbApj bGFzcyBNYWluV2luZG93KG1vZGVsLkJhY2tncm91bmQpOgoJZGVmICBvbl9T bGlkZXIxX21vdXNlVXAoc2VsZiwgZXZlbnQpOgoJCXNsaWRlclZhbHVlID0g c2VsZi5jb21wb25lbnRzLlNsaWRlcjEudmFsdWUKCQlmb250ID0gc2VsZi5j b21wb25lbnRzLlRleHRBcmVhMS5HZXRGb250KCkKCQlmb250LlNldFBvaW50 U2l6ZShzbGlkZXJWYWx1ZSkKCQlzZWxmLmNvbXBvbmVudHMuVGV4dEFyZWEx LlNldEZvbnQoZm9udCkKCQphcHAgPSBtb2RlbC5BcHBsaWNhdGlvbihNYWlu V2luZG93KQphcHAuTWFpbkxvb3AoKQoKCgo= --0-429441989-1308678224=:55592 Content-Type: application/octet-stream; name="pc_slider_text.rsrc.py" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pc_slider_text.rsrc.py" eydhcHBsaWNhdGlvbic6eyd0eXBlJzonQXBwbGljYXRpb24nLA0KICAgICAg ICAgICduYW1lJzonVGVtcGxhdGUnLA0KICAgICdiYWNrZ3JvdW5kcyc6IFsN CiAgICB7J3R5cGUnOidCYWNrZ3JvdW5kJywNCiAgICAgICAgICAnbmFtZSc6 J2JnVGVtcGxhdGUnLA0KICAgICAgICAgICd0aXRsZSc6J1N0YW5kYXJkIFRl bXBsYXRlIHdpdGggRmlsZS0+RXhpdCBtZW51JywNCiAgICAgICAgICAnc2l6 ZSc6KDQwMCwgMzAwKSwNCiAgICAgICAgICAnc3R5bGUnOlsncmVzaXplYWJs ZSddLA0KDQogICAgICAgICdtZW51YmFyJzogeyd0eXBlJzonTWVudUJhcics DQogICAgICAgICAnbWVudXMnOiBbDQogICAgICAgICAgICAgeyd0eXBlJzon TWVudScsDQogICAgICAgICAgICAgJ25hbWUnOidtZW51RmlsZScsDQogICAg ICAgICAgICAgJ2xhYmVsJzonJkZpbGUnLA0KICAgICAgICAgICAgICdpdGVt cyc6IFsNCiAgICAgICAgICAgICAgICAgIHsndHlwZSc6J01lbnVJdGVtJywN CiAgICAgICAgICAgICAgICAgICAnbmFtZSc6J21lbnVGaWxlRXhpdCcsDQog ICAgICAgICAgICAgICAgICAgJ2xhYmVsJzonRSZ4aXQnLA0KICAgICAgICAg ICAgICAgICAgICdjb21tYW5kJzonZXhpdCcsDQogICAgICAgICAgICAgICAg ICB9LA0KICAgICAgICAgICAgICBdDQogICAgICAgICAgICAgfSwNCiAgICAg ICAgIF0NCiAgICAgfSwNCiAgICAgICAgICdjb21wb25lbnRzJzogWw0KDQp7 J3R5cGUnOidTbGlkZXInLCANCiAgICAnbmFtZSc6J1NsaWRlcjEnLCANCiAg ICAncG9zaXRpb24nOig1OSwgMTczKSwgDQogICAgJ3NpemUnOig5OCwgMzEp LCANCiAgICAnbGFiZWxzJzpGYWxzZSwgDQogICAgJ2xheW91dCc6J2hvcml6 b250YWwnLCANCiAgICAnbWF4Jzo1MCwgDQogICAgJ21pbic6NCwgDQogICAg J3RpY2tGcmVxdWVuY3knOjAsIA0KICAgICd0aWNrcyc6RmFsc2UsIA0KICAg ICd2YWx1ZSc6NCwgDQogICAgfSwNCg0Keyd0eXBlJzonVGV4dEFyZWEnLCAN CiAgICAnbmFtZSc6J1RleHRBcmVhMScsIA0KICAgICdwb3NpdGlvbic6KDE5 LCAyMSksIA0KICAgICdzaXplJzooMjY1LCAxMTQpLCANCiAgICAndGV4dCc6 dSdUZXh0QXJlYTEnLCANCiAgICB9LA0KDQpdICMgZW5kIGNvbXBvbmVudHMN Cn0gIyBlbmQgYmFja2dyb3VuZA0KXSAjIGVuZCBiYWNrZ3JvdW5kcw0KfSB9 DQo= --0-429441989-1308678224=:55592 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 --0-429441989-1308678224=:55592 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 --0-429441989-1308678224=:55592--