python - GTK3 multiple UI files -


i tying make login form using python , gtk3 of anjuta. far, have ui file login section, , form makes http request. class looks this:

class gui:     def __init__(self):         self.builder = gtk.builder()         self.builder.add_from_file(ui_file)         self.builder.connect_signals(self)          window = self.builder.get_object('window')         window.set_title("login")          window.show_all()         self.username = ''         self.password = '' 

when fill in correct data, http request successful , can see response in console. want clear current window (ui file) , load new 1 in place. is, without closing actual window , opening new one. how do that?

let's have ui file

    <?xml version="1.0" encoding="utf-8"?>     <!-- generated glade 3.15.3 on tue sep 17 10:11:35 2013 -->     <interface>       <!-- interface-requires gtk+ 3.10 -->       <object class="gtkgrid" id="grid2">         <property name="visible">true</property>         <property name="row_spacing">12</property>         <property name="row_homogeneous">true</property>         <child>           <object class="gtklabel" id="label1">             <property name="visible">true</property>             <property name="label" translatable="yes">i'm widget new content</property>           </object>           <packing>             <property name="left_attach">0</property>             <property name="top_attach">0</property>             <property name="width">1</property>             <property name="height">1</property>           </packing>         </child>         <child>           <object class="gtklabel" id="label2">             <property name="visible">true</property>             <property name="label" translatable="yes">me too</property>           </object>           <packing>             <property name="left_attach">0</property>             <property name="top_attach">1</property>             <property name="width">1</property>             <property name="height">1</property>           </packing>         </child>       </object>       <object class="gtkwindow" id="window1">         <child>           <object class="gtkgrid" id="grid1">             <property name="visible">true</property>             <child>               <object class="gtkbutton" id="button1">                 <property name="label" translatable="yes">button</property>                 <property name="visible">true</property>               </object>               <packing>                 <property name="left_attach">0</property>                 <property name="top_attach">0</property>                 <property name="width">1</property>                 <property name="height">1</property>               </packing>             </child>             <child>               <object class="gtkbutton" id="button2">                 <property name="label" translatable="yes">button</property>                 <property name="visible">true</property>               </object>               <packing>                 <property name="left_attach">1</property>                 <property name="top_attach">1</property>                 <property name="width">1</property>                 <property name="height">1</property>               </packing>             </child>             <child>               <object class="gtkbutton" id="button3">                 <property name="label" translatable="yes">button</property>                 <property name="visible">true</property>               </object>               <packing>                 <property name="left_attach">2</property>                 <property name="top_attach">2</property>                 <property name="width">1</property>                 <property name="height">1</property>               </packing>             </child>           </object>         </child>       </object>     </interface> 

now, create window usual:

    window1 = self.builder.get_object('window2')     window1.show_all() 

if want change content of window. need destroy/hide widget want hide.

    grid1 = self.builder.get_object('grid1')     grid1.destroy()     grid2 = self.builder.get_object('grid2')     window1.add (grid2) 

and we're go. can load second widget hierarchy (grid2, mean) same initial ui file or new one. need understand, after builder create objects ui files, can't modify further.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -