New to Glade/Pygtk



Hi, group!
I'm sure this is an FAQ, but: I have been working with Python for a few years but not with GUI interface.
I'm trying to get a simple script going that I can use to build on functionality later.
Right now I just want to send a character string to a GtkScrolledWindow "text_view"
So later I can pipe standard input to python and have it show up in a GUI window so a user can read it at 
leisure  and close it when done.
If anyone has any insights on this and/or can suggest some textbooks I could read on the subject I'd be more 
than happy!
Thanks for your time.
:)
K.W.


**** begin python ****

import sys
import pygtk
pygtk.require("2.0")
import gtk


class TutorialTextEditor(object):

    def on_window_destroy(self, widget, data=None):
        gtk.main_quit()

    def __init__(self):

        builder = gtk.Builder()
        builder.add_from_file("py_pkglist2.xml")

        self.window = builder.get_object("main_window")
                dic = {"on_window_destroy" : gtk.main_quit, "on_quit_button_clicked" : gtk.main_quit}
                builder.connect_signals(dic)

                lst = "Hello World"

                label = gtk.Label(lst)  #  <== this does not work, but I just need to send multiple status 
strings to
                                                     #  <object class="GtkTextView" id="textview1">
                                   #  a child of <object class="GtkScrolledWindow" id="text_view">



if __name__ == "__main__":
    editor = TutorialTextEditor()
    editor.window.show()
    # gtk.main()
    gtk.main()

*****  end python ***

**** start Glade xml file ****
<?xml version="1.0"?>
<interface>
  <requires lib="gtk+" version="2.16"/>
  <!-- interface-naming-policy project-wide -->
  <object class="GtkWindow" id="main_window">
    <property name="visible">True</property>
    <property name="title" translatable="yes">Gtk+ Status List</property>
    <property name="default_width">300</property>
    <property name="default_height">85</property>
    <signal name="destroy" handler="on_window_destroy"/>
    <child>
      <object class="GtkVBox" id="vbox1">
        <property name="visible">True</property>
        <property name="orientation">vertical</property>
        <child>
          <placeholder/>
        </child>
        <child>
          <object class="GtkScrolledWindow" id="text_view">
            <property name="width_request">2</property>
            <property name="height_request">2</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="border_width">1</property>
            <property name="hscrollbar_policy">automatic</property>
            <property name="vscrollbar_policy">automatic</property>
            <property name="shadow_type">etched-in</property>
            <child>
              <object class="GtkTextView" id="textview1">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="editable">False</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToolbar" id="toolbar1">
            <property name="visible">True</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="quit_button">
            <property name="label">gtk-quit</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_stock">True</property>
            <signal name="clicked" handler="on_quit_button_clicked"/>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">False</property>
            <property name="position">3</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>

*** end code  ***


The Department of Environmental Protection values your feedback as a customer. DEP Secretary Michael W. Sole 
is committed to continuously assessing and improving the level and quality of services provided to you. 
Please take a few minutes to comment on the quality of service you received. Simply click on this link to the 
DEP Customer Survey<http://survey.dep.state.fl.us/?refemail=Keith Wood dep state fl us>. Thank you in advance 
for completing the survey.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]