Hi... I have this addLink button, that calls the addLinkClick function. content is a multiline text control.
The following are variables: href,target,linkName
I want this button to print

print "<a href='"+href+"' target='"+target+"'>"+linkName+"</a>"

into the content control.

How do I do this?
Also...does anybody now how to run a wxPython .py application?

Recommended Answers

All 2 Replies

Let's assume you have Windows on your box. Toggle to plain text, then highlight, copy and paste the code below into your editor, save it as wxtext101.py (or such). If Python and wxPython is properly installed, double-click on the filename to run it:

import wx

class MyPanel(wx.Panel):
    """panel with multiline text control"""
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)
        self.SetBackgroundColour("green")

        self.edit3 = wx.TextCtrl(self, -1, value="", pos=(10, 10),
                size=(300, 125), style=wx.TE_MULTILINE)

        #print "<a href='"+href+"' target='"+target+"'>"+linkName+"</a>"
        href = 'fi'
        target = 'fo'
        linkName = 'fum'
        str1 = "print "+"<a href='"+href+"' target='"+target+"'>"+linkName+"</a>"
        self.edit3.SetValue(str1)


app = wx.PySimpleApp()
# create window/frame, no parent, -1 is default ID
frame = wx.Frame(None, -1, "wx.TextCtrl", size = (400, 310))
# -1 is default ID
MyPanel(frame,-1)
frame.Show(True)
app.MainLoop()

Oh it ran! thank you!

But what I want is to put a textbox where you can type in something instead of fum, for instance. In other words, you type something in the textbox, click a button, and the outcome is printed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.