Re: Dynamically change font size of a TextArea
hwg <[email protected]> Tue, 21 Jun 2011 07:23:43 -0700 (PDT)
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
--===============3102597929109063481== Content-Type: multipart/alternative; boundary="0-1112063886-1308666223=:18781" --0-1112063886-1308666223=:18781 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable I tried both of the methods below:=0A=0AI get the following error:=0A=0ATra= ceback (most recent call last):=0A=A0File "C:\Python25\lib\site-packages\Py= thonCard\widget.py", line 408, in _dispatch=0Ahandler(background, aWxEvent)= =0A=A0File "C:\Users\wsande\Documents\Warren\PythonScripts\PC_slider_text\p= c_slider_text.py", line 11, in on_Slider1_mouseUp=0Afont.SetPointSize(slide= rValue)=0AAttributeError: 'Font' object has no attribute 'SetPointSize'=0A= =0A=0AHere's the complete code:=0A=0A# pc_slider_text.py=0A# try to change = the size of text font in a test box using a slider=0A=0A=0Afrom wx import *= =0Afrom PythonCard import model=0Aclass MainWindow(model.Background):=0A=A0= =A0=A0 def=A0 on_Slider1_mouseUp(self, event):=0A=A0=A0=A0 =A0=A0=A0 slider= Value =3D self.components.Slider1.value=0A=A0=A0=A0 =A0=A0=A0 print sliderV= alue=0A=A0=A0=A0 =A0=A0=A0 font =3D self.components.TextArea1.font=0A=A0=A0= =A0 =A0=A0=A0 font.SetPointSize(sliderValue)=0A=A0=A0=A0 =A0=A0=A0 self.com= ponents.TextArea1.SetFont(font)=0A=A0=A0=A0 =A0=A0=A0 print self.components= .TextArea1.font=0A=0Aapp =3D model.Application(MainWindow)=0Aapp.MainLoop()= =0A=0A=0A=0A>________________________________=0A>From: Lawrence Abbott <law= [email protected]>=0A>To: hwg <[email protected]>=0A>Sent: Monday, June 20, 2011= 10:37 PM=0A>Subject: Re: [Pythoncard-users] Dynamically change font size o= f a TextArea=0A>=0A>A slightly cleaner way=0A>=0A>=A0 =A0 =A0 =A0 font =3D = self.components.TextArea1.GetFont()=0A>=A0 =A0 =A0 =A0 font.SetPointSize(16= )=0A>=A0 =A0 =A0 =A0 self.components.TextArea1.SetFont(font)=0A>=0A>Cheers,= =0A>Lawrie=0A>=0A>On Tue, Jun 21, 2011 at 12:26 PM, Lawrence Abbott <lawabb= @gmail.com> wrote:=0A>> Hi,=0A>>=0A>> self.components.TextArea1.font_size = =3D sliderValue=0A>>=0A>> doesnt work for me=0A>>=0A>> print self.component= s.TextArea1.font.size=0A>>=0A>> gives a dictionary of font attributes, but = I can't get them to update either=0A>>=0A>> import wx=0A>>=0A>> font_size = =3D16=0A>>=0A>> font1 =3D self.components.TextArea1.GetFont()=0A>> font2 = =3D wx.Font(font_size, font1.Family, font1.Style, font1.Weight)=0A>> self.c= omponents.TextArea1.SetFont( font2 )=0A>>=0A>> seems to work=0A>>=0A>> HTH,= =0A>> Lawrie=0A>>=0A>> On Mon, Jun 20, 2011 at 2:27 AM, hwg <[email protected]= om> wrote:=0A>>> I tried:=0A>>>=0A>>> self.components.TextArea1.font_size = =3D sliderValue=0A>>> It doesn't throw an exception, but it doesn't change = the font size, either.=0A>>> Also, oddly, the slider never seems to lose fo= cus.=A0 It keeps sliding back=0A>>> and forth even after the mouse is relea= sed and no longer over the slider.=A0 I=0A>>> can't get focus on the TextAr= ea.=0A>>>=0A>>>=0A>>> - hwg=0A>>>=0A>>>=0A>>> _____________________________= ___=0A>>> From: "[email protected]" <[email protected]>=0A>>> To: hwg <hwg4= [email protected]>=0A>>> Cc: "[email protected]"=0A>>> <pyt= [email protected]>=0A>>> Sent: Saturday, June 18, 2011 11= :45 PM=0A>>> Subject: Re: [Pythoncard-users] Dynamically change font size o= f a TextArea=0A>>>=0A>>> font is not a dictionary.=A0 It's a class.=A0 Try = font._size=0A>>>=0A>>> On 6/17/2011 1:23 PM, hwg wrote:=0A>>>=0A>>> from Py= thonCard import model=0A>>> class MainWindow(model.Background):=0A>>> =A0= =A0 def=A0 on_Slider1_mouseUp(self, event):=0A>>> =A0=A0=A0=A0=A0=A0 slider= Value =3D self.components.Slider1.value=0A>>> =A0=A0=A0=A0=A0=A0=A0self.com= ponents.TextArea1.font['size'] =3D sliderValue=0A>>>=0A>>> app =3D model.Ap= plication(MainWindow)=0A>>> app.MainLoop()=0A>>>=0A>>> --=0A>>> Kim Cheung= =0A>>>=0A>>>=0A>>> --------------------------------------------------------= ----------------------=0A>>> EditLive Enterprise is the world's most techni= cally advanced content=0A>>> authoring tool. Experience the power of Track = Changes, Inline Image=0A>>> Editing and ensure content is compliant with Ac= cessibility Checking.=0A>>> http://p.sf.net/sfu/ephox-dev2dev=0A>>> _______= ________________________________________=0A>>> Pythoncard-users mailing lis= t=0A>>> [email protected]=0A>>> https://lists.sourcefo= rge.net/lists/listinfo/pythoncard-users=0A>>>=0A>>>=0A>>=0A>=0A>=0A> --0-1112063886-1308666223=:18781 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable <html><body><div style=3D"color:#000; background-color:#fff; font-family:Co= urier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div>I tr= ied both of the methods below:</div><div><br></div><div>I get the following= error:</div><div style=3D"font-family:Courier New, courier, monaco, monosp= ace, sans-serif;"><br></div><div><span style=3D"font-family:Courier New, co= urier, monaco, monospace, sans-serif;">Traceback (most recent call last):</= span><br style=3D"font-family:Courier New, courier, monaco, monospace, sans= -serif;"><span style=3D"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=3D"font-family:Courier New, cou= rier, monaco, monospace, sans-serif;"><span style=3D"font-family:Courier Ne= w, courier, monaco, monospace, sans-serif;">handler(background, aWxEvent)</= span><br style=3D"font-family:Courier New, courier, monaco, monospace, sans-serif;"><span style=3D"font-family:Courier New, courier, monaco, mono= space, sans-serif;"> File "C:\Users\wsande\Documents\Warren\PythonScri= pts\PC_slider_text\pc_slider_text.py", line 11, in on_Slider1_mouseUp</span= ><br style=3D"font-family:Courier New, courier, monaco, monospace, sans-ser= if;"><span style=3D"font-family:Courier New, courier, monaco, monospace, sa= ns-serif;">font.SetPointSize(sliderValue)</span><br style=3D"font-family:Co= urier New, courier, monaco, monospace, sans-serif;"><span style=3D"font-fam= ily: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=3D"font-fami= ly:Courier New, courier, monaco, monospace, sans-serif;"># <a target=3D"_bl= ank" href=3D"http://pc_slider_text.py/"><span class=3D"yshortcuts" id=3D"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=3D"font-family:Cou= rier New, courier, monaco, monospace, sans-serif;">from wx import *</span><= br style=3D"font-family:Courier New, courier, monaco, monospace, sans-serif= ;"><span style=3D"font-family:Courier New, courier, monaco, monospace, sans= -serif;">from PythonCard import model</span><br style=3D"font-family:Courie= r New, courier, monaco, monospace, sans-serif;"><span style=3D"font-family:= Courier New, courier, monaco, monospace, sans-serif;">class MainWindow(mode= l.Background):</span><br style=3D"font-family:Courier New, courier, monaco,= monospace, sans-serif;"><span style=3D"font-family:Courier New, courier, m= onaco, monospace, sans-serif;"> def on_Slider1_mous= eUp(self, event):</span><br style=3D"font-family:Courier New, courier, mona= co, monospace, sans-serif;"><span style=3D"font-family:Courier New, courier= , monaco, monospace, sans-serif;"> sli= derValue =3D self.components.Slider1.value</span><br style=3D"font-family:Courier New, = courier, monaco, monospace, sans-serif;"><span style=3D"font-family:Courier= New, courier, monaco, monospace, sans-serif;"> &nb= sp; print sliderValue</span><br style=3D"font-family:Courier New, cou= rier, monaco, monospace, sans-serif;"><span style=3D"font-family:Courier Ne= w, courier, monaco, monospace, sans-serif;"> = font =3D self.components.TextArea1.font</span><br style=3D"font-fami= ly:Courier New, courier, monaco, monospace, sans-serif;"><span style=3D"fon= t-family:Courier New, courier, monaco, monospace, sans-serif;"> = font.SetPointSize(sliderValue)</span><br style=3D= "font-family:Courier New, courier, monaco, monospace, sans-serif;"><span st= yle=3D"font-family:Courier New, courier, monaco, monospace, sans-serif;">&n= bsp; self.components.TextArea1.SetFont(font)= </span><br style=3D"font-family:Courier New, courier, monaco, monospace, sans-serif;"= ><span style=3D"font-family:Courier New, courier, monaco, monospace, sans-s= erif;"> =0A print self.components.TextA= rea1.font</span><br style=3D"font-family:Courier New, courier, monaco, mono= space, sans-serif;"><span style=3D"font-family:Courier New, courier, monaco= , monospace, sans-serif;"></span></div><div><span style=3D"font-family:Cour= ier New, courier, monaco, monospace, sans-serif;"><br></span></div><span st= yle=3D"font-family:Courier New, courier, monaco, monospace, sans-serif;">a<= /span><span style=3D"font-family:Courier New, courier, monaco, monospace, s= ans-serif;">pp =3D model.Application(MainWindow)</span><br style=3D"font-fa= mily:Courier New, courier, monaco, monospace, sans-serif;"><span style=3D"f= ont-family:Courier New, courier, monaco, monospace, sans-serif;">app.MainLo= op()</span><div><br><blockquote style=3D"border-left: 2px solid rgb(16, 16,= 255); margin-left: 5px; padding-left: 5px;"><div style=3D"font-family: Cou= rier New, courier, monaco, monospace, sans-serif; font-size: 10pt;"><div st= yle=3D"font-family: times new roman, new york, times, serif; font-size: 12pt;"><font size=3D"2" face=3D"Arial"><hr = size=3D"1"><b><span style=3D"font-weight:bold;">From:</span></b> Lawrence A= bbott <[email protected]><br><b><span style=3D"font-weight: bold;">To:= </span></b> hwg <[email protected]><br><b><span style=3D"font-weight: = bold;">Sent:</span></b> Monday, June 20, 2011 10:37 PM<br><b><span style=3D= "font-weight: bold;">Subject:</span></b> Re: [Pythoncard-users] Dynamically= change font size of a TextArea<br></font><br>=0AA slightly cleaner way<br>= <br> font =3D self.components.TextArea1.GetFont(= )<br> font.SetPointSize(16)<br> &nb= sp; self.components.TextArea1.SetFont(font)<br><br>Cheers,<br>Lawrie= <br><br>On Tue, Jun 21, 2011 at 12:26 PM, Lawrence Abbott <<a ymailto=3D= "mailto:[email protected]" href=3D"mailto:[email protected]">[email protected]= </a>> wrote:<br>> Hi,<br>><br>> self.components.TextArea1.font_= size =3D sliderValue<br>><br>> doesnt work for me<br>><br>> pri= nt self.components.TextArea1.font.size<br>><br>> gives a dictionary o= f font attributes, but I can't get them to update either<br>><br>> im= port wx<br>><br>> font_size =3D16<br>><br>> font1 =3D self.comp= onents.TextArea1.GetFont()<br>> font2 =3D wx.Font(font_size, font1.Famil= y, font1.Style, font1.Weight)<br>> self.components.TextArea1.SetFont( fo= nt2 )<br>><br>> seems to work<br>><br>> HTH,<br>> Lawrie<br>><br>> On Mon, Jun 20, 2011 at 2:27 AM, hwg &= lt;<a ymailto=3D"mailto:[email protected]" href=3D"mailto:[email protected]">= [email protected]</a>> wrote:<br>>> I tried:<br>>><br>>>= ; self.components.TextArea1.font_size =3D sliderValue<br>>> It doesn'= t throw an exception, but it doesn't change the font size, either.<br>>&= gt; Also, oddly, the slider never seems to lose focus. It keeps slidi= ng back<br>>> and forth even after the mouse is released and no longe= r over the slider. I<br>>> can't get focus on the TextArea.<br>= >><br>>><br>>> - hwg<br>>><br>>><br>>> = ________________________________<br>>> From: "<a ymailto=3D"mailto:ec= [email protected]" href=3D"mailto:[email protected]">[email protected]</a>" &= lt;<a ymailto=3D"mailto:[email protected]" href=3D"mailto:[email protected]= ">[email protected]</a>><br>>> To: hwg <<a ymailto=3D"mailto:[email protected]" href=3D"mailto:[email protected]">hwg43= [email protected]</a>><br>>> Cc: "<a ymailto=3D"mailto:pythoncard-users@= lists.sourceforge.net" href=3D"mailto:[email protected]= t">[email protected]</a>"<br>>> <<a ymailto= =3D"mailto:[email protected]" href=3D"mailto:pythoncar= [email protected]">[email protected]</a>&g= t;<br>>> Sent: Saturday, June 18, 2011 11:45 PM<br>>> Subject: = Re: [Pythoncard-users] Dynamically change font size of a TextArea<br>>&g= t;<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(mode= l.Background):<br>>> def on_Slider1_mouseUp(self, = event):<br>>> sliderValue =3D self.components.Slider1.value<br>>> &n= bsp; self.components.TextArea1.font['size'] =3D sliderValue<br>>>= ;<br>>> app =3D model.Application(MainWindow)<br>>> app.MainLoo= p()<br>>><br>>> --<br>>> Kim Cheung<br>>><br>>&g= t;<br>>> ------------------------------------------------------------= ------------------<br>>> EditLive Enterprise is the world's most tech= nically advanced content<br>>> authoring tool. Experience the power o= f Track Changes, Inline Image<br>>> Editing and ensure content is com= pliant with Accessibility Checking.<br>>> http://p.sf.net/sfu/ephox-d= ev2dev<br>>> _______________________________________________<br>>&= gt; Pythoncard-users mailing list<br>>> <a ymailto=3D"mailto:Pythonca= [email protected]" href=3D"mailto:[email protected]= eforge.net">[email protected]</a><br>>> <a href=3D"https://lists.sourceforge.net/lists/listinfo/pythoncard-users" tar= get=3D"_blank">https://lists.sourceforge.net/lists/listinfo/pythoncard-user= s</a><br>>><br>>><br>><br><br><br></div></div></blockquote><= /div></div></body></html> --0-1112063886-1308666223=:18781-- --===============3102597929109063481== 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 --===============3102597929109063481== 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 --===============3102597929109063481==--