Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert Text into a TextBuffer via a Function - python
    primarykey
    data
    text
    <p>I have following problem:</p> <p>How can i insert text in my textbuffer?</p> <p><strong>Interface.py</strong></p> <pre><code>class MainWindow: def __init__(self): # Build our Interface from the XML/Glade file gladefile = "MainWindow.glade" try: self.builder = Gtk.Builder() self.builder.add_from_file(gladefile) except: print("Failed to load Glade file: %s" % gladefile) # Connect signals self.builder.connect_signals(self) # Get the widgets self.window = self.builder.get_object("MainWindow") ... # TextViews self.TextViewCommandInput = self.builder.get_object("TextViewCommandInput") self.TextViewCommandOutput = self.builder.get_object("TextViewCommandOutput") ... def DrawCommandView(output): TextBufferCommandInput = MainWindow.TextViewCommandInput.get_buffer() TextBufferCommandInput.insert_at_cursor(output + "\n") </code></pre> <p>And import "DrawCommandView" in a file </p> <p><strong>Commands.py</strong></p> <pre><code>from Interface import MainWindow, DrawCommandView output = "Hello World" DrawCommandView(output) if __name__ == "__main__": StartMainWindow = MainWindow() StartMainWindow.main() </code></pre> <p>But I keep getting this error:</p> <pre><code>Traceback (most recent call last): File "/home/user/Dokumente/Workspace/project/Commands.py", line 5, in &lt;module&gt; DrawACommandView(output) File "/home/user/Dokumente/Workspace/project/Interface.py", line 182, in DrawCommandView TextBufferCommandInput = MainWindow.TextViewCommandInput.get_buffer() AttributeError: class MainWindow has no attribute 'self' </code></pre> <p><strong>Thanks for your help!</strong></p> <p>greetz</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload