Re: Dynamically change font size of a TextArea
hwg <[email protected]> Tue, 21 Jun 2011 15:14:32 -0700 (PDT)
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
--===============0293671298436224841== Content-Type: multipart/alternative; boundary="0-1303499748-1308694472=:98706" --0-1303499748-1308694472=:98706 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable That's what I needed.=A0 Working perfectly now.=A0 (I also removed the unne= cessary wx import.)=0A=0AI don't understand why I need the event.Skip().=A0= If someone could explain, it would be much appreciated.=0A=0A=0Ahwg=0A=0A= =0A=0A=0A>________________________________=0A>From: Lawrence Abbott <lawabb= @gmail.com>=0A>To: hwg <[email protected]>=0A>Cc: pythoncard-users <pythonca= [email protected]>=0A>Sent: Tuesday, June 21, 2011 2:06 PM=0A>= Subject: Re: [Pythoncard-users] Dynamically change font size of a TextArea= =0A>=0A>Try adding an=0A>=0A>event.Skip()=0A>=0A>As mentioned previously - = no need for the wx import.=0A>=0A>Cheers,=0A>Lawrie=0A>=0A>On Wed, Jun 22, = 2011 at 1:43 AM, hwg <[email protected]> wrote:=0A>> Lawrie,=0A>>=0A>> That = works.=A0 Thanks!=0A>>=0A>> I still have a weird issue where the Slider doe= sn't give up focus.=A0 I start=0A>> dragging it, and when I release it (mou= seUp), the event handler fires and=0A>> the font size changes.=A0 But I can= 't enter the TextArea, and the slider still=0A>> moves around as I move the= mouse, even with no mouse buttons pressed.=A0 I=0A>> can't access the Text= Area or the Menu, and I can't even close the PythonCard=0A>> app window wit= hout going into the IDE and stopping the script from there.=0A>>=0A>> Any i= dea what's causing this?=0A>>=0A>> Complete code is attached.=0A>>=0A>>=0A>= > Thanks,=0A>> hwg=0A>>=0A>>=0A>> ________________________________=0A>> Fro= m: Lawrence Abbott <[email protected]>=0A>> To: hwg <[email protected]>=0A>> = Cc: pythoncard-users <[email protected]>=0A>> Sent: Tu= e, June 21, 2011 7:45:50 AM=0A>> Subject: Re: [Pythoncard-users] Dynamicall= y change font size of a TextArea=0A>>=0A>> try=0A>> font =3D self.component= s.TextArea1.GetFont()=0A>>=0A>> instead of=0A>> font =3D self.components.Te= xtArea1.font=0A>>=0A>> also you will need to ensure the slider output value= s are legitimate font=0A>> sizes=0A>> also should be no need to import wx w= ith SetPointSize method=0A>>=0A>> Cheers,=0A>> Lawrie=0A>>=0A>>=0A>> On Tue= , Jun 21, 2011 at 10:23 PM, hwg <[email protected]> wrote:=0A>>> I tried bot= h of the methods below:=0A>>> I get the following error:=0A>>> Traceback (m= ost recent call last):=0A>>> =A0File "C:\Python25\lib\site-packages\PythonC= ard\widget.py", line 408, in=0A>>> _dispatch=0A>>> handler(background, aWxE= vent)=0A>>> =A0File=0A>>>=0A>>> "C:\Users\wsande\Documents\Warren\PythonScr= ipts\PC_slider_text\pc_slider_text.py",=0A>>> line 11, in on_Slider1_mouseU= p=0A>>> font.SetPointSize(sliderValue)=0A>>> AttributeError: 'Font' object = has no attribute 'SetPointSize'=0A>>>=0A>>> Here's the complete code:=0A>>>= # pc_slider_text.py=0A>>> # try to change the size of text font in a test = box using a slider=0A>>>=0A>>> from wx import *=0A>>> from PythonCard impor= t model=0A>>> class MainWindow(model.Background):=0A>>> =A0=A0=A0 def=A0 on= _Slider1_mouseUp(self, event):=0A>>> =A0=A0=A0 =A0=A0=A0 sliderValue =3D se= lf.components.Slider1.value=0A>>> =A0=A0=A0 =A0=A0=A0 print sliderValue=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= .components.TextArea1.SetFont(font)=0A>>> =A0=A0=A0 =A0=A0=A0 print self.co= mponents.TextArea1.font=0A>>>=0A>>> app =3D model.Application(MainWindow)= =0A>>> app.MainLoop()=0A>>>=0A>>> ________________________________=0A>>> Fr= om: Lawrence Abbott <[email protected]>=0A>>> To: hwg <[email protected]>=0A>= >> Sent: Monday, June 20, 2011 10:37 PM=0A>>> Subject: Re: [Pythoncard-user= s] Dynamically change font size of a TextArea=0A>>>=0A>>> A slightly cleane= r way=0A>>>=0A>>> =A0 =A0 =A0 =A0 font =3D self.components.TextArea1.GetFon= t()=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 <[email protected]>= =0A>>> wrote:=0A>>>> Hi,=0A>>>>=0A>>>> self.components.TextArea1.font_size = =3D sliderValue=0A>>>>=0A>>>> doesnt work for me=0A>>>>=0A>>>> print self.c= omponents.TextArea1.font.size=0A>>>>=0A>>>> gives a dictionary of font attr= ibutes, but I can't get them to update=0A>>>> either=0A>>>>=0A>>>> import w= x=0A>>>>=0A>>>> font_size =3D16=0A>>>>=0A>>>> font1 =3D self.components.Tex= tArea1.GetFont()=0A>>>> font2 =3D wx.Font(font_size, font1.Family, font1.St= yle, font1.Weight)=0A>>>> self.components.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]> 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,=0A>>>= >> either.=0A>>>>> Also, oddly, the slider never seems to lose focus.=A0 It= keeps sliding=0A>>>>> back=0A>>>>> and forth even after the mouse is relea= sed and no longer over the=0A>>>>> slider.=A0 I=0A>>>>> can't get focus on = the TextArea.=0A>>>>>=0A>>>>>=0A>>>>> - hwg=0A>>>>>=0A>>>>>=0A>>>>> _______= _________________________=0A>>>>> From: "[email protected]" <ecs1749@gmail.= com>=0A>>>>> To: hwg <[email protected]>=0A>>>>> Cc: "pythoncard-users@lists= .sourceforge.net"=0A>>>>> <[email protected]>=0A>>>>> = Sent: Saturday, June 18, 2011 11:45 PM=0A>>>>> Subject: Re: [Pythoncard-use= rs] Dynamically change font size of a=0A>>>>> 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 PythonCard import model= =0A>>>>> class MainWindow(model.Background):=0A>>>>> =A0=A0 def=A0 on_Slide= r1_mouseUp(self, event):=0A>>>>> =A0=A0=A0=A0=A0=A0 sliderValue =3D self.co= mponents.Slider1.value=0A>>>>> =A0=A0=A0=A0=A0=A0=A0self.components.TextAre= a1.font['size'] =3D sliderValue=0A>>>>>=0A>>>>> app =3D model.Application(M= ainWindow)=0A>>>>> app.MainLoop()=0A>>>>>=0A>>>>> --=0A>>>>> Kim Cheung=0A>= >>>>=0A>>>>>=0A>>>>>=0A>>>>>=0A>>>>> --------------------------------------= ----------------------------------------=0A>>>>> EditLive Enterprise is the= world's most technically advanced content=0A>>>>> authoring tool. Experien= ce the power of Track Changes, Inline Image=0A>>>>> Editing and ensure cont= ent is compliant with Accessibility Checking.=0A>>>>> http://p.sf.net/sfu/e= phox-dev2dev=0A>>>>> _______________________________________________=0A>>>>= > Pythoncard-users mailing list=0A>>>>> [email protected].= net=0A>>>>> https://lists.sourceforge.net/lists/listinfo/pythoncard-users= =0A>>>>>=0A>>>>>=0A>>>>=0A>>>=0A>>>=0A>>>=0A>>>=0A>>> ---------------------= ---------------------------------------------------------=0A>>> EditLive En= terprise is the world's most technically advanced content=0A>>> authoring t= ool. Experience the power of Track Changes, Inline Image=0A>>> Editing and = ensure content is compliant with Accessibility Checking.=0A>>> http://p.sf.= net/sfu/ephox-dev2dev=0A>>> _______________________________________________= =0A>>> Pythoncard-users mailing list=0A>>> [email protected]= ge.net=0A>>> https://lists.sourceforge.net/lists/listinfo/pythoncard-users= =0A>>>=0A>>>=0A>>=0A>=0A>=0A> --0-1303499748-1308694472=:98706 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><spa= n>That's what I needed. Working perfectly now. (I also removed = the unnecessary wx import.)</span></div><div><br><span></span></div><div><s= pan>I don't understand why I need the event.Skip(). If someone could = explain, it would be much appreciated.</span></div><div><br><span></span></= div><div><br><span></span></div><div><span>hwg</span></div><div><span><br><= /span></div><div><br><blockquote style=3D"border-left: 2px solid rgb(16, 16= , 255); margin-left: 5px; padding-left: 5px;"><div style=3D"font-family: Co= urier New, courier, monaco, monospace, sans-serif; font-size: 10pt;"><div s= tyle=3D"font-family: times new roman, new york, times, serif; font-size: 12= pt;"><font size=3D"2" face=3D"Arial"><hr size=3D"1"><b><span style=3D"font-= weight:bold;">From:</span></b> Lawrence Abbott <[email protected]><br>= <b><span style=3D"font-weight: bold;">To:</span></b> hwg <[email protected]><b= r><b><span style=3D"font-weight: bold;">Cc:</span></b> pythoncard-users <= ;[email protected]><br><b><span style=3D"font-weigh= t: bold;">Sent:</span></b> Tuesday, June 21, 2011 2:06 PM<br><b><span style= =3D"font-weight: bold;">Subject:</span></b> Re: [Pythoncard-users] Dynamica= lly change font size of a TextArea<br></font><br>=0ATry adding an<br><br>ev= ent.Skip()<br><br>As mentioned previously - no need for the wx import.<br><= br>Cheers,<br>Lawrie<br><br>On Wed, Jun 22, 2011 at 1:43 AM, hwg <<a yma= ilto=3D"mailto:[email protected]" href=3D"mailto:[email protected]">hwg434@ya= hoo.com</a>> wrote:<br>> Lawrie,<br>><br>> That works. Th= anks!<br>><br>> I still have a weird issue where the Slider doesn't g= ive up focus. I start<br>> dragging it, and when I release it (mou= seUp), the event handler fires and<br>> the font size changes. But= I can't enter the TextArea, and the slider still<br>> moves around as I= move the mouse, even with no mouse buttons pressed. I<br>> can't = access the TextArea or the Menu, and I can't even close the PythonCard<br>&= gt; app window without going into the IDE and stopping the script from ther= e.<br>><br>> Any idea what's causing this?<br>><br>> Complete c= ode is attached.<br>><br>><br>> Thanks,<br>> hwg<br>><br>><br>> ______________________________= __<br>> From: Lawrence Abbott <<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]"= >[email protected]</a>><br>> Cc: pythoncard-users <<a ymailto=3D"ma= ilto:[email protected]" href=3D"mailto:pythoncard-user= [email protected]">[email protected]</a>><br>= > Sent: Tue, June 21, 2011 7:45:50 AM<br>> Subject: Re: [Pythoncard-u= sers] Dynamically change font size of a TextArea<br>><br>> try<br>>= ; font =3D self.components.TextArea1.GetFont()<br>><br>> instead of<b= r>> font =3D self.components.TextArea1.font<br>><br>> also you wil= l need to ensure the slider output values are legitimate font<br>> sizes= <br>> also should be no need to import wx with SetPointSize method<br>><br>> Cheers,<br>> Lawrie<br>><br>><br>> On T= ue, Jun 21, 2011 at 10:23 PM, hwg <<a ymailto=3D"mailto:[email protected]= " href=3D"mailto:[email protected]">[email protected]</a>> wrote:<br>>&= gt; I tried both of the methods below:<br>>> I get the following erro= r:<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>>> Fil= e<br>>><br>>> "C:\Users\wsande\Documents\Warren\PythonScripts\P= C_slider_text\pc_slider_text.py",<br>>> line 11, in on_Slider1_mouseU= p<br>>> font.SetPointSize(sliderValue)<br>>> AttributeError: 'F= ont' object has no attribute 'SetPointSize'<br>>><br>>> Here's = the complete code:<br>>> # <a target=3D"_blank" href=3D"http://pc_sli= der_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 imp= ort *<br>>> from PythonCard import model<br>>> class MainWindow= (model.Background):<br>>> def on_Slider1_mou= seUp(self, event):<br>>> slider= Value =3D self.components.Slider1.value<br>>> &nbs= p; print sliderValue<br>>>  = ; font =3D self.components.TextArea1.font<br>>> &nb= sp; font.SetPointSize(sliderValue)<br>>> &nb= sp; self.components.TextArea1.SetFont(font)<br>>= ;> print self.components.TextArea1= .font<br>>><br>>> app =3D model.Application(MainWindow)<br>>= > app.MainLoop()<br>>><br>>> _______________________________= _<br>>> From: Lawrence Abbott <<a ymailto=3D"mailto:[email protected]" href=3D"mailto:[email protected]">lawab= [email protected]</a>><br>>> To: hwg <<a ymailto=3D"mailto:hwg434@yah= oo.com" href=3D"mailto:[email protected]">[email protected]</a>><br>>&g= t; Sent: Monday, June 20, 2011 10:37 PM<br>>> Subject: Re: [Pythoncar= d-users] Dynamically change font size of a TextArea<br>>><br>>>= A slightly cleaner way<br>>><br>>> = font =3D self.components.TextArea1.GetFont()<br>>> &nb= sp; font.SetPointSize(16)<br>>> se= lf.components.TextArea1.SetFont(font)<br>>><br>>> Cheers,<br>&g= t;> Lawrie<br>>><br>>> On Tue, Jun 21, 2011 at 12:26 PM, Law= rence Abbott <<a ymailto=3D"mailto:[email protected]" href=3D"mailto:lawa= [email protected]">[email protected]</a>><br>>> wrote:<br>>>> H= i,<br>>>><br>>>> self.components.TextArea1.font_size =3D sliderValue<br>>>><br>>>> doesnt work for me<br>>>= ><br>>>> print self.components.TextArea1.font.size<br>>>&= gt;<br>>>> gives a dictionary of font attributes, but I can't get = them to update<br>>>> either<br>>>><br>>>> impor= t wx<br>>>><br>>>> font_size =3D16<br>>>><br>>= ;>> font1 =3D self.components.TextArea1.GetFont()<br>>>> fon= t2 =3D wx.Font(font_size, font1.Family, font1.Style, font1.Weight)<br>>&= gt;> self.components.TextArea1.SetFont( font2 )<br>>>><br>>&= gt;> seems to work<br>>>><br>>>> HTH,<br>>>> = Lawrie<br>>>><br>>>> On Mon, Jun 20, 2011 at 2:27 AM, hwg= <<a ymailto=3D"mailto:[email protected]" href=3D"mailto:[email protected]= ">[email protected]</a>> wrote:<br>>>>> I tried:<br>>>&= gt;><br>>>>> self.components.TextArea1.font_size =3D sliderValue<br>>>>> It doesn't throw an exception, but it does= n't change the font size,<br>>>>> either.<br>>>>> A= lso, oddly, the slider never seems to lose focus. It keeps sliding<br= >>>>> back<br>>>>> and forth even after the mouse i= s released and no longer over the<br>>>>> slider. I<br>&g= t;>>> can't get focus on the TextArea.<br>>>>><br>>= >>><br>>>>> - hwg<br>>>>><br>>>>&= gt;<br>>>>> ________________________________<br>>>>>= ; From: "<a ymailto=3D"mailto:[email protected]" href=3D"mailto:ecs1749@gma= il.com">[email protected]</a>" <<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:hwg4= [email protected]">[email protected]</a>><br>>>>> Cc: "<a ymailto=3D"mailto:[email protected]" href=3D"mailto:p= [email protected]">[email protected]= et</a>"<br>>>>> <<a ymailto=3D"mailto:pythoncard-users@lists= .sourceforge.net" href=3D"mailto:[email protected]">py= [email protected]</a>><br>>>>> Sent: Satu= rday, June 18, 2011 11:45 PM<br>>>>> Subject: Re: [Pythoncard-u= sers] Dynamically change font size of a<br>>>>> TextArea<br>>= ;>>><br>>>>> font is not a dictionary. It's a cl= ass. Try font._size<br>>>>><br>>>>> On 6/17/2= 011 1:23 PM, hwg wrote:<br>>>>><br>>>>> from Python= Card import model<br>>>>> class MainWindow(model.Background):<b= r>>>>> def on_Slider1_mouseUp(self, event):<= br>>>>> sliderValue =3D self.components.Slider1.value<br>>>>> = self.components.TextArea1.font['size'] =3D sliderValue<br= >>>>><br>>>>> app =3D model.Application(MainWindow)= <br>>>>> app.MainLoop()<br>>>>><br>>>>>= --<br>>>>> Kim Cheung<br>>>>><br>>>>><= br>>>>><br>>>>><br>>>>> ---------------= ---------------------------------------------------------------<br>>>= >> EditLive Enterprise is the world's most technically advanced conte= nt<br>>>>> authoring tool. Experience the power of Track Change= s, Inline Image<br>>>>> Editing and ensure content is compliant= with Accessibility Checking.<br>>>>> http://p.sf.net/sfu/ephox= -dev2dev<br>>>>> ______________________________________________= _<br>>>>> Pythoncard-users mailing list<br>>>>> <a ymailto=3D"mailto:[email protected]" href=3D"mailt= o:[email protected]">[email protected]= e.net</a><br>>>>> <a href=3D"https://lists.sourceforge.net/list= s/listinfo/pythoncard-users" target=3D"_blank">https://lists.sourceforge.ne= t/lists/listinfo/pythoncard-users</a><br>>>>><br>>>>&g= t;<br>>>><br>>><br>>><br>>><br>>><br>>&= gt; -----------------------------------------------------------------------= -------<br>>> EditLive Enterprise is the world's most technically adv= anced content<br>>> authoring tool. Experience the power of Track Cha= nges, Inline Image<br>>> Editing and ensure content is compliant with= Accessibility Checking.<br>>> <a href=3D"http://p.sf.net/sfu/ephox-d= ev2dev" target=3D"_blank">http://p.sf.net/sfu/ephox-dev2dev</a><br>>>= _______________________________________________<br>>> Pythoncard-use= rs mailing list<br>>> <a ymailto=3D"mailto:[email protected]= eforge.net" href=3D"mailto:[email protected]">Pythonca= [email protected]</a><br>>> <a href=3D"https://lists.sou= rceforge.net/lists/listinfo/pythoncard-users" target=3D"_blank">https://lis= ts.sourceforge.net/lists/listinfo/pythoncard-users</a><br>>><br>>&= gt;<br>><br><br><br></div></div></blockquote></div></div></body></html> --0-1303499748-1308694472=:98706-- --===============0293671298436224841== 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 --===============0293671298436224841== 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 --===============0293671298436224841==--