Re: Dynamically change font size of a TextArea

Lawrence Abbott <[email protected]> Wed, 22 Jun 2011 05:06:34 +0800
Newsgroups gmane.comp.python.pythoncard
Message-ID <[email protected]>
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 s=
tart
> 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 PythonC=
ard
> 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 =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_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):
>> =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 TextAr=
ea
>>
>> 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 slider=
Value
>>>>
>>>> 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
>>
>>
>

---------------------------------------------------------------------------=
---
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