473,396 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to set wxTextCtrl style to wxHSCROLL?

Tim
How can I set the style attribute in the following wxTextCtrl to a new
style AFTER I have already instantiated the wxTextCtrl? I'm trying to
toggle the word wrap attribute of the wxTextCtrl, just like Edit->Word
Wrap does in Windows Notepad. (I'm building a Windows Notepad clone
in wxPython to prove to a VB friend that it can be done.)

Here is the wxTextCtrl instantiation:

--------------
self.txtEditor = wxTextCtrl(id=wxID_WXFRAME1TXTEDITOR,
name='txtEditor',
parent=self, pos=wxPoint(0, 0), size=wxSize(760, 492),
style=wxTE_MULTILINE, value='')
--------------

Here is the code I've tried to set the style to a new value:

--------------
def OnMnuEditWordwrapMenu(self, event):
# TODO: implement word wrap
self.txtEditor.SetStyle(0, self.txtEditor.GetLastPosition(),
wxHSCROLL)
#self.txtEditor.style = 'wxHSCROLL'

--------------

What is the correct syntax?

Thanks!

Tim
Jul 18 '05 #1
2 3282

"Tim" <ti*******@yahoo.com> wrote in message
news:b8*************************@posting.google.co m...
How can I set the style attribute in the following wxTextCtrl to a new
style AFTER I have already instantiated the wxTextCtrl? I'm trying to
toggle the word wrap attribute of the wxTextCtrl, just like Edit->Word
Wrap does in Windows Notepad. (I'm building a Windows Notepad clone
in wxPython to prove to a VB friend that it can be done.)

Here is the wxTextCtrl instantiation:

--------------
self.txtEditor = wxTextCtrl(id=wxID_WXFRAME1TXTEDITOR,
name='txtEditor',
parent=self, pos=wxPoint(0, 0), size=wxSize(760, 492),
style=wxTE_MULTILINE, value='')
--------------

Here is the code I've tried to set the style to a new value:

--------------
def OnMnuEditWordwrapMenu(self, event):
# TODO: implement word wrap
self.txtEditor.SetStyle(0, self.txtEditor.GetLastPosition(),
wxHSCROLL)
#self.txtEditor.style = 'wxHSCROLL'

--------------

What is the correct syntax?

Thanks!

Tim

I might try
import wx

self.txtEditor.style = wx.HSCROLL
#wx.HSCROLL if an integer constant
self.txtEditor.Refresh()

You should be useing something like wx.StyledTextCtrl which has all of the
functionality built in. One thing you don't need to prove to any programmer
is that Python can be as difficult as any language. Find the proper library
to do your task, import it and use it.

Tom
Jul 18 '05 #2
Tim
Thank you! I couldn't get the wxTextCtrl style to change using the
method you suggested, but I tried the StyledTextCtrl which works
wonderfully! : ) It made the more complex functionality easier to
implement all-around.

Tim
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: fowlertrainer | last post by:
Hello ! I want to create a tool for mp3 files in wx. Some sections of the code (see below) is copied from wx demo. Problems: 1.) the wxStaticText is not centered vertically 2.) the...
3
by: hellprout | last post by:
hi , i have a problem with a wxtextctrl with multiline option. i want to write a file , line after line , in my wxtextctrl . But my file is too longer , and the wxtextctrl can't write the end of...
3
by: Russ Phillips | last post by:
I'm just starting to learn Python & wxPython. I have a frame named frSend in a file fSend. On this frame is a wxTextCtrl named txtMsg. I have a module named defs.py I would like to get the value...
2
by: Nicolas Pourcelot | last post by:
Hello, my script worked well until today : when I tried to launch it, I got the following : frame = MyFrame(None,-1,"Geometrie",size=wx.Size(600,400)) File...
0
by: austin | last post by:
I produced 5 wxTextCtrl. My program is to let the user enter the serial number. Each wxTextCtrl has 4 maxlength. My ideal is if the user enter 4 digits on first wxTextCtrl, and the program will...
4
by: Clans Of Intrigue | last post by:
Hello, this is my first post here so apologies if it's in the wrong place, inappropriate or embarrassingly stupid - please let me know :) My problem seems quite simple - I've redirected stdout to...
0
by: alyph | last post by:
Hi, I'm using wxTextCtrl in python (wxPython 2.6, python 2.4). And I used the SetStyle function to change color of some text already shown in the TextCtrl. Everything works fine excpet if I set...
0
by: abcd | last post by:
I have a wxTextCtrl: wx.TextCtrl(self.myPanel, -1, "", style=wx.TE_MULTILINE) I take a set of text (65,000 characters), and paste it into the text control. all looks well. Then when I click...
0
by: ilSignorCarlo | last post by:
Hi, I'd like to display a string in a wxTextCtrl where some selected chars have a different colour from the others. Is there any way a char by specifying is position?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.