Esempio n. 1
0
        def __init__(self, delegate=Delegate()):
            gtk.VBox.__init__(self, 25)
            self.set_border_width(25)

            #
            # model
            self.delegate = delegate
            self.instr_s = PrototypeController.PrototypeView.instructions()
            self.instr_buf = gtk.TextBuffer()
            self.instr_buf.set_text(self.instr_s)

            #
            # ui
            self.vbox1 = gtk.VBox()

            #
            # vbox1
            # top: instructions
            # middle: entry
            # bottom: generate code+unicode picker
            #

            #
            # top
            self.instr = gtk.TextView(self.instr_buf)
            self.instr.set_editable(False)
            self.instr.set_wrap_mode(gtk.WRAP_WORD)

            #
            # middle
            hbox = gtk.HBox()
            label = gtk.Label("Desired Button Label: ")
            self.entry = gtk.Entry()
            hbox.pack_start(label, False)
            hbox.pack_start(self.entry)

            #
            # bottom
            self.gen1button = gtk.Button("Generate Code")
            self.unibutton = gtk.Button("Unicode Picker")
            # hook up button clicks
            self.gen1button.connect("clicked", self.gen1_clicked)
            self.unibutton.connect("clicked", self.uni_clicked)

            # add components to vbox
            self.vbox1.pack_start(self.instr, False)
            self.vbox1.pack_start(hbox)
            self.vbox1.pack_start(self.unibutton, False)
            self.vbox1.pack_start(self.gen1button, False)
            self.vbox1.show()
            self.add(self.vbox1)

            #
            # vbox2
            # name field
            # button layout info field
            #

            self.vbox2 = gtk.VBox()
            hbox1 = gtk.HBox()
            # title
            title_label = gtk.Label('Controller Title: ')
            self.title_entry = gtk.Entry()
            hbox1.pack_start(title_label, False)
            hbox1.pack_start(self.title_entry)
            # tl
            hbox2 = gtk.HBox()
            tl_label = gtk.Label('Top-Left Description: ')
            self.tl_entry = gtk.Entry()
            hbox2.pack_start(tl_label, False)
            hbox2.pack_start(self.tl_entry)
            # tr
            hbox3 = gtk.HBox()
            tr_label = gtk.Label('Top-Right Description: ')
            self.tr_entry = gtk.Entry()
            hbox3.pack_start(tr_label, False)
            hbox3.pack_start(self.tr_entry)
            # bl
            hbox4 = gtk.HBox()
            bl_label = gtk.Label('Bottom-Left Description: ')
            self.bl_entry = gtk.Entry()
            hbox4.pack_start(bl_label, False)
            hbox4.pack_start(self.bl_entry)
            # bm
            hbox5 = gtk.HBox()
            bm_label = gtk.Label('Bottom-Middle Description: ')
            self.bm_entry = gtk.Entry()
            hbox5.pack_start(bm_label, False)
            hbox5.pack_start(self.bm_entry)
            # br
            hbox6 = gtk.HBox()
            br_label = gtk.Label('Bottom-Right Description: ')
            self.br_entry = gtk.Entry()
            hbox6.pack_start(br_label, False)
            hbox6.pack_start(self.br_entry)

            # buttons
            self.back = gtk.Button('Go Back')
            self.gen2button = gtk.Button('Generate Code')
            # hook em up
            self.back.connect('clicked', self.go2gen1)
            self.gen2button.connect('clicked', self.gen2_clicked)

            self.vbox2.pack_start(hbox1)
            self.vbox2.pack_start(hbox2)
            self.vbox2.pack_start(hbox3)
            self.vbox2.pack_start(hbox4)
            self.vbox2.pack_start(hbox5)
            self.vbox2.pack_start(hbox6)
            self.vbox2.pack_start(self.back, False)
            self.vbox2.pack_start(self.gen2button, False)

            self.vbox2.show_all()

            #
            # embed the unicode picker in the view
            self.unicode_view = UnicodePickerView(self)
            self.unicode_view.show_all()
Esempio n. 2
0
    def __init__( self, delegate=Delegate() ):
      gtk.VBox.__init__( self, 25 )
      self.set_border_width( 25 )

      #
      # model
      self.delegate = delegate
      self.instr_s = PrototypeController.PrototypeView.instructions()
      self.instr_buf = gtk.TextBuffer()
      self.instr_buf.set_text(self.instr_s)
   
      #
      # ui
      self.vbox1 = gtk.VBox()
      
      #
      # vbox1
      # top: instructions
      # middle: entry
      # bottom: generate code+unicode picker
      #

      #
      # top
      self.instr = gtk.TextView( self.instr_buf )
      self.instr.set_editable( False )
      self.instr.set_wrap_mode( gtk.WRAP_WORD )

      #
      # middle
      hbox = gtk.HBox()
      label = gtk.Label("Desired Button Label: ")
      self.entry = gtk.Entry()
      hbox.pack_start( label, False )
      hbox.pack_start( self.entry )

      #
      # bottom
      self.gen1button = gtk.Button( "Generate Code" )
      self.unibutton = gtk.Button( "Unicode Picker" )
      # hook up button clicks
      self.gen1button.connect( "clicked", self.gen1_clicked )
      self.unibutton.connect( "clicked", self.uni_clicked )
  
      # add components to vbox
      self.vbox1.pack_start( self.instr, False )
      self.vbox1.pack_start( hbox )
      self.vbox1.pack_start( self.unibutton, False )
      self.vbox1.pack_start( self.gen1button, False )
      self.vbox1.show()
      self.add( self.vbox1 )
  
      #
      # vbox2
      # name field
      # button layout info field
      #

      self.vbox2 = gtk.VBox()
      hbox1 = gtk.HBox()
      # title
      title_label = gtk.Label( 'Controller Title: ' )
      self.title_entry = gtk.Entry()
      hbox1.pack_start(title_label,False)
      hbox1.pack_start(self.title_entry)
      # tl
      hbox2 = gtk.HBox()
      tl_label = gtk.Label( 'Top-Left Description: ' )
      self.tl_entry = gtk.Entry()
      hbox2.pack_start(tl_label,False)
      hbox2.pack_start(self.tl_entry)
      # tr
      hbox3 = gtk.HBox()
      tr_label = gtk.Label( 'Top-Right Description: ' )
      self.tr_entry = gtk.Entry()
      hbox3.pack_start(tr_label,False)
      hbox3.pack_start(self.tr_entry)
      # bl
      hbox4 = gtk.HBox()
      bl_label = gtk.Label( 'Bottom-Left Description: ' )
      self.bl_entry = gtk.Entry()
      hbox4.pack_start(bl_label,False)
      hbox4.pack_start(self.bl_entry)
      # bm
      hbox5 = gtk.HBox()
      bm_label = gtk.Label( 'Bottom-Middle Description: ' )
      self.bm_entry = gtk.Entry()
      hbox5.pack_start(bm_label,False)
      hbox5.pack_start(self.bm_entry)
      # br
      hbox6 = gtk.HBox()
      br_label = gtk.Label( 'Bottom-Right Description: ' )
      self.br_entry = gtk.Entry()
      hbox6.pack_start(br_label,False)
      hbox6.pack_start(self.br_entry)

      # buttons
      self.back = gtk.Button('Go Back')
      self.gen2button = gtk.Button('Generate Code')
      # hook em up
      self.back.connect( 'clicked', self.go2gen1 )
      self.gen2button.connect( 'clicked', self.gen2_clicked )

      self.vbox2.pack_start( hbox1 )
      self.vbox2.pack_start( hbox2 )
      self.vbox2.pack_start( hbox3 )
      self.vbox2.pack_start( hbox4 )
      self.vbox2.pack_start( hbox5 )
      self.vbox2.pack_start( hbox6 )
      self.vbox2.pack_start( self.back, False )
      self.vbox2.pack_start( self.gen2button, False )

      self.vbox2.show_all()

      #
      # embed the unicode picker in the view
      self.unicode_view = UnicodePickerView(self)
      self.unicode_view.show_all()
Esempio n. 3
0
    class PrototypeView(gtk.VBox, Lifecycle, UnicodePickerView.Delegate):
        class Delegate():
            def generate_code(self, info):
                pass

        def gen1_clicked(self, view):
            self.remove(self.vbox1)
            self.add(self.vbox2)
            # such a hack...
            self.title_entry.set_text(self.delegate._tm_label)

        def go2gen1(self, view):
            self.remove(self.vbox2)
            self.add(self.vbox1)

        def gen2_clicked(self, view):
            x = {}
            x['title'] = self.title_entry.get_text()
            x['tl'] = self.tl_entry.get_text()
            x['tr'] = self.tr_entry.get_text()
            x['bl'] = self.bl_entry.get_text()
            x['bm'] = self.bm_entry.get_text()
            x['br'] = self.br_entry.get_text()
            self.delegate.generate_code(x)

        def uni_clicked(self, view):
            # swap the views
            self.remove(self.vbox1)
            self.add(self.unicode_view)

        #
        # unicode picker delegate
        def did_select_unicode(self, val):
            old = self.entry.get_text()
            old += val
            self.entry.set_text(old)
            # swap the views
            self.remove(self.unicode_view)
            self.add(self.vbox1)

        def __init__(self, delegate=Delegate()):
            gtk.VBox.__init__(self, 25)
            self.set_border_width(25)

            #
            # model
            self.delegate = delegate
            self.instr_s = PrototypeController.PrototypeView.instructions()
            self.instr_buf = gtk.TextBuffer()
            self.instr_buf.set_text(self.instr_s)

            #
            # ui
            self.vbox1 = gtk.VBox()

            #
            # vbox1
            # top: instructions
            # middle: entry
            # bottom: generate code+unicode picker
            #

            #
            # top
            self.instr = gtk.TextView(self.instr_buf)
            self.instr.set_editable(False)
            self.instr.set_wrap_mode(gtk.WRAP_WORD)

            #
            # middle
            hbox = gtk.HBox()
            label = gtk.Label("Desired Button Label: ")
            self.entry = gtk.Entry()
            hbox.pack_start(label, False)
            hbox.pack_start(self.entry)

            #
            # bottom
            self.gen1button = gtk.Button("Generate Code")
            self.unibutton = gtk.Button("Unicode Picker")
            # hook up button clicks
            self.gen1button.connect("clicked", self.gen1_clicked)
            self.unibutton.connect("clicked", self.uni_clicked)

            # add components to vbox
            self.vbox1.pack_start(self.instr, False)
            self.vbox1.pack_start(hbox)
            self.vbox1.pack_start(self.unibutton, False)
            self.vbox1.pack_start(self.gen1button, False)
            self.vbox1.show()
            self.add(self.vbox1)

            #
            # vbox2
            # name field
            # button layout info field
            #

            self.vbox2 = gtk.VBox()
            hbox1 = gtk.HBox()
            # title
            title_label = gtk.Label('Controller Title: ')
            self.title_entry = gtk.Entry()
            hbox1.pack_start(title_label, False)
            hbox1.pack_start(self.title_entry)
            # tl
            hbox2 = gtk.HBox()
            tl_label = gtk.Label('Top-Left Description: ')
            self.tl_entry = gtk.Entry()
            hbox2.pack_start(tl_label, False)
            hbox2.pack_start(self.tl_entry)
            # tr
            hbox3 = gtk.HBox()
            tr_label = gtk.Label('Top-Right Description: ')
            self.tr_entry = gtk.Entry()
            hbox3.pack_start(tr_label, False)
            hbox3.pack_start(self.tr_entry)
            # bl
            hbox4 = gtk.HBox()
            bl_label = gtk.Label('Bottom-Left Description: ')
            self.bl_entry = gtk.Entry()
            hbox4.pack_start(bl_label, False)
            hbox4.pack_start(self.bl_entry)
            # bm
            hbox5 = gtk.HBox()
            bm_label = gtk.Label('Bottom-Middle Description: ')
            self.bm_entry = gtk.Entry()
            hbox5.pack_start(bm_label, False)
            hbox5.pack_start(self.bm_entry)
            # br
            hbox6 = gtk.HBox()
            br_label = gtk.Label('Bottom-Right Description: ')
            self.br_entry = gtk.Entry()
            hbox6.pack_start(br_label, False)
            hbox6.pack_start(self.br_entry)

            # buttons
            self.back = gtk.Button('Go Back')
            self.gen2button = gtk.Button('Generate Code')
            # hook em up
            self.back.connect('clicked', self.go2gen1)
            self.gen2button.connect('clicked', self.gen2_clicked)

            self.vbox2.pack_start(hbox1)
            self.vbox2.pack_start(hbox2)
            self.vbox2.pack_start(hbox3)
            self.vbox2.pack_start(hbox4)
            self.vbox2.pack_start(hbox5)
            self.vbox2.pack_start(hbox6)
            self.vbox2.pack_start(self.back, False)
            self.vbox2.pack_start(self.gen2button, False)

            self.vbox2.show_all()

            #
            # embed the unicode picker in the view
            self.unicode_view = UnicodePickerView(self)
            self.unicode_view.show_all()

        def update(self):
            pass

        def clear(self):
            self.entry.set_text("")

        @staticmethod
        def instructions():
            y = 'Instructions:\n'
            y += '- insert text in the \'Desired Button Label\' field below and click a corner button to fill with that text.\n'
            y += '- clicking the \'Unicode Picker\' button will display a table of clickable Unicode characters\n'
            y += '- clicking the \'Generate Code\'  button will display an interface to create a template Controller class '
            y += 'with the specified button labels'
            return y
Esempio n. 4
0
  class PrototypeView( gtk.VBox, Lifecycle, UnicodePickerView.Delegate ):
    class Delegate():
      def generate_code( self, info ):
        pass
    
    def gen1_clicked( self, view ):
      self.remove(self.vbox1)
      self.add(self.vbox2)
      # such a hack...
      self.title_entry.set_text( self.delegate._tm_label )
  
    def go2gen1( self, view ):
      self.remove(self.vbox2)
      self.add(self.vbox1)
    
    def gen2_clicked( self, view ):
      x = {}
      x['title'] = self.title_entry.get_text()
      x['tl'] = self.tl_entry.get_text()
      x['tr'] = self.tr_entry.get_text()
      x['bl'] = self.bl_entry.get_text()
      x['bm'] = self.bm_entry.get_text()
      x['br'] = self.br_entry.get_text()
      self.delegate.generate_code( x )
   
    def uni_clicked( self, view ):
      # swap the views
      self.remove( self.vbox1 )
      self.add( self.unicode_view )
 
    # 
    # unicode picker delegate
    def did_select_unicode( self, val ):
      old = self.entry.get_text()
      old += val
      self.entry.set_text(old)
      # swap the views
      self.remove(self.unicode_view)
      self.add(self.vbox1)

    def __init__( self, delegate=Delegate() ):
      gtk.VBox.__init__( self, 25 )
      self.set_border_width( 25 )

      #
      # model
      self.delegate = delegate
      self.instr_s = PrototypeController.PrototypeView.instructions()
      self.instr_buf = gtk.TextBuffer()
      self.instr_buf.set_text(self.instr_s)
   
      #
      # ui
      self.vbox1 = gtk.VBox()
      
      #
      # vbox1
      # top: instructions
      # middle: entry
      # bottom: generate code+unicode picker
      #

      #
      # top
      self.instr = gtk.TextView( self.instr_buf )
      self.instr.set_editable( False )
      self.instr.set_wrap_mode( gtk.WRAP_WORD )

      #
      # middle
      hbox = gtk.HBox()
      label = gtk.Label("Desired Button Label: ")
      self.entry = gtk.Entry()
      hbox.pack_start( label, False )
      hbox.pack_start( self.entry )

      #
      # bottom
      self.gen1button = gtk.Button( "Generate Code" )
      self.unibutton = gtk.Button( "Unicode Picker" )
      # hook up button clicks
      self.gen1button.connect( "clicked", self.gen1_clicked )
      self.unibutton.connect( "clicked", self.uni_clicked )
  
      # add components to vbox
      self.vbox1.pack_start( self.instr, False )
      self.vbox1.pack_start( hbox )
      self.vbox1.pack_start( self.unibutton, False )
      self.vbox1.pack_start( self.gen1button, False )
      self.vbox1.show()
      self.add( self.vbox1 )
  
      #
      # vbox2
      # name field
      # button layout info field
      #

      self.vbox2 = gtk.VBox()
      hbox1 = gtk.HBox()
      # title
      title_label = gtk.Label( 'Controller Title: ' )
      self.title_entry = gtk.Entry()
      hbox1.pack_start(title_label,False)
      hbox1.pack_start(self.title_entry)
      # tl
      hbox2 = gtk.HBox()
      tl_label = gtk.Label( 'Top-Left Description: ' )
      self.tl_entry = gtk.Entry()
      hbox2.pack_start(tl_label,False)
      hbox2.pack_start(self.tl_entry)
      # tr
      hbox3 = gtk.HBox()
      tr_label = gtk.Label( 'Top-Right Description: ' )
      self.tr_entry = gtk.Entry()
      hbox3.pack_start(tr_label,False)
      hbox3.pack_start(self.tr_entry)
      # bl
      hbox4 = gtk.HBox()
      bl_label = gtk.Label( 'Bottom-Left Description: ' )
      self.bl_entry = gtk.Entry()
      hbox4.pack_start(bl_label,False)
      hbox4.pack_start(self.bl_entry)
      # bm
      hbox5 = gtk.HBox()
      bm_label = gtk.Label( 'Bottom-Middle Description: ' )
      self.bm_entry = gtk.Entry()
      hbox5.pack_start(bm_label,False)
      hbox5.pack_start(self.bm_entry)
      # br
      hbox6 = gtk.HBox()
      br_label = gtk.Label( 'Bottom-Right Description: ' )
      self.br_entry = gtk.Entry()
      hbox6.pack_start(br_label,False)
      hbox6.pack_start(self.br_entry)

      # buttons
      self.back = gtk.Button('Go Back')
      self.gen2button = gtk.Button('Generate Code')
      # hook em up
      self.back.connect( 'clicked', self.go2gen1 )
      self.gen2button.connect( 'clicked', self.gen2_clicked )

      self.vbox2.pack_start( hbox1 )
      self.vbox2.pack_start( hbox2 )
      self.vbox2.pack_start( hbox3 )
      self.vbox2.pack_start( hbox4 )
      self.vbox2.pack_start( hbox5 )
      self.vbox2.pack_start( hbox6 )
      self.vbox2.pack_start( self.back, False )
      self.vbox2.pack_start( self.gen2button, False )

      self.vbox2.show_all()

      #
      # embed the unicode picker in the view
      self.unicode_view = UnicodePickerView(self)
      self.unicode_view.show_all()
   
    def update( self ):
      pass

    def clear( self ):
      self.entry.set_text("")
    
    @staticmethod
    def instructions(): 
      y = 'Instructions:\n'
      y += '- insert text in the \'Desired Button Label\' field below and click a corner button to fill with that text.\n'
      y += '- clicking the \'Unicode Picker\' button will display a table of clickable Unicode characters\n' 
      y += '- clicking the \'Generate Code\'  button will display an interface to create a template Controller class '
      y += 'with the specified button labels'
      return y