From: Lawrence A. <la...@gm...> - 2011-06-21 14:45:57
|
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 <hw...@ya...> 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 <la...@gm...> > To: hwg <hw...@ya...> > 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 <la...@gm...> 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 <hw...@ya...> 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: "ec...@gm..." <ec...@gm...> >>> To: hwg <hw...@ya...> >>> Cc: "pyt...@li..." >>> <pyt...@li...> >>> 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 >>> Pyt...@li... >>> 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 > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > > |