Re: Dynamically change font size of a TextArea
Lawrence Abbott <[email protected]> Wed, 22 Jun 2011 13:12:18 +0800
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
On-line documentation is going to do a more thorough and accurate job than I can do :( ....try these http://wiki.wxpython.org/EventPropagation http://wiki.wxpython.org/self.Bind%20vs.%20self.button.Bind remembering PythonCard is a wrapper of wxpython Cheers, Lawrie On Wed, Jun 22, 2011 at 6:14 AM, hwg <[email protected]> wrote: > That's what I needed.=A0 Working perfectly now.=A0 (I also removed the > unnecessary wx import.) > I don't understand why I need the event.Skip().=A0 If someone could expla= in, > it would be much appreciated. > > hwg > > ________________________________ > From: Lawrence Abbott <[email protected]> > To: hwg <[email protected]> > Cc: pythoncard-users <[email protected]> > Sent: Tuesday, June 21, 2011 2:06 PM > Subject: Re: [Pythoncard-users] Dynamically change font size of a TextArea > > Try adding an > > event.Skip() > > As mentioned previously - no need for the wx import. > > Cheers, > Lawrie > > On Wed, Jun 22, 2011 at 1:43 AM, hwg <[email protected]> wrote: >> Lawrie, >> >> That works.=A0 Thanks! >> >> I still have a weird issue where the Slider doesn't give up focus.=A0 I >> start >> dragging it, and when I release it (mouseUp), the event handler fires and >> the font size changes.=A0 But I can't enter the TextArea, and the slider >> still >> moves around as I move the mouse, even with no mouse buttons pressed.=A0= 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 TextAr= ea >> >> try >> font =3D self.components.TextArea1.GetFont() >> >> instead of >> font =3D 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): >>> =A0File "C:\Python25\lib\site-packages\PythonCard\widget.py", line 408,= in >>> _dispatch >>> handler(background, aWxEvent) >>> =A0File >>> >>> >>> "C:\Users\wsande\Documents\Warren\PythonScripts\PC_slider_text\pc_slide= r_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): >>> =A0=A0=A0 def=A0 on_Slider1_mouseUp(self, event): >>> =A0=A0=A0 =A0=A0=A0 sliderValue =3D self.components.Slider1.value >>> =A0=A0=A0 =A0=A0=A0 print sliderValue >>> =A0=A0=A0 =A0=A0=A0 font =3D self.components.TextArea1.font >>> =A0=A0=A0 =A0=A0=A0 font.SetPointSize(sliderValue) >>> =A0=A0=A0 =A0=A0=A0 self.components.TextArea1.SetFont(font) >>> =A0=A0=A0 =A0=A0=A0 print self.components.TextArea1.font >>> >>> app =3D 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 >>> >>> =A0 =A0 =A0 =A0 font =3D self.components.TextArea1.GetFont() >>> =A0 =A0 =A0 =A0 font.SetPointSize(16) >>> =A0 =A0 =A0 =A0 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 =3D 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 =3D16 >>>> >>>> font1 =3D self.components.TextArea1.GetFont() >>>> font2 =3D 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 =3D 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.=A0 It keeps sliding >>>>> back >>>>> and forth even after the mouse is released and no longer over the >>>>> slider.=A0 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.=A0 It's a class.=A0 Try font._size >>>>> >>>>> On 6/17/2011 1:23 PM, hwg wrote: >>>>> >>>>> from PythonCard import model >>>>> class MainWindow(model.Background): >>>>> =A0=A0 def=A0 on_Slider1_mouseUp(self, event): >>>>> =A0=A0=A0=A0=A0=A0 sliderValue =3D self.components.Slider1.value >>>>> =A0=A0=A0=A0=A0=A0=A0self.components.TextArea1.font['size'] =3D slide= rValue >>>>> >>>>> app =3D 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 >>> >>> >> > > > ---------------------------------------------------------------------------= --- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Data protection magic? Nope - It's vRanger. Get your free trial download today. http://p.sf.net/sfu/quest-sfdev2dev