From: Kevin A. <al...@se...> - 2004-09-26 20:37:20
|
On Sep 26, 2004, at 12:23 PM, Gordon Webster wrote: > Dear Pythoncard BB > > I have created a TextArea control in my app, it > automatically has a vertical scroll bar but the text > is too wide for the control. How do I tell it to > include a horizontal scroll bar? > > I still don't understand how i get at the wx level of > a given pythoncard control - what is the hook? > > I tried suff like e.g. > self.components.myTextArea.style = wx.HSCROLL. > > Any help would be greatly appreciated. There are no > horizontal scrollbars in any of the sample apps. > > Best > > Gordon > The issue of providing alternate styles for the underlying controls with PythonCard has been a long-standing one, so let me give a little background before suggesting some possible solutions. I would like to get feedback on the styleOverride idea below. There has been a general goal of focusing on the most commonly used style for a component as the default and if there are multiple common variations then there are typically extra attributes that let you choose those styles as alternatives. Most of the underlying wxPython controls, only let you set the style when the control is initialized, so the style information must be available during the __init__ method of the component. For a long time PythonCard also avoided wrapping components or supporting styles that weren't available on all platforms, to simplify writing cross-platform code. That is no longer true, and so you have controls like the IEHtmlWindow which only works on Windows. On the other hand, the TextArea control will continue to use the wx.TE_RICH2 style so that it behaves almost identically on Mac, Linux, and Windows. Personally, I don't want to have a corresponding style attribute for every possible style available in the underlying wxPython control since more choices just makes it more difficult to use, so the trick is figuring out which are the common cases and supporting those. In the case of the horizontal scrollbar, which is optional on Windows, but not on GTK, I can see having a specific attribute to control the setting, but it still won't allow the scrollbar to be toggled once the control is created because wxWidgets doesn't support that. A general solution to this problem would be to have something like a styleOverride attribute for components that would be for expert users that need complete control over the style flags. One implementation that might work would be to make it a list of strings such as ['wx.TE_RICH2', 'wx.TE_MULTILINE', 'wx.HSCROLL']. By default styleOverride would be None, but if it exists, each style string would be converted into a style flag using eval() and logically ORed (|) with the other styles and used instead of the normal style processing. That power would also mean you could easily create a program that wouldn't run correctly, especially if you made a typo, but also because you didn't include all the required style options, so it definitely would be an expert option and I'm not sure what changes might be necessary to protect normal users from styleOverride in the resourceEditor. Anyone have opinions on this idea? If you want a solution today, then you can make your own TextArea component that uses the wx.HSCROLL style. A better solution might be to simply use the CodeEditor component since it supports unwrapped text and a horizontal scrollbar already. The life sample uses the CodeEditor component for both the Lexicon and Patterns windows. The CodeEditor component does allow wrapped text to be toggled on and off. ka |