def chooseFile(self, textview):
     dialog = gtk.FileChooserDialog("Open..", None, gtk.FILE_CHOOSER_ACTION_OPEN,(gtk.STOCK_OPEN, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
     dialog.set_default_response(gtk.RESPONSE_OK)
     response = dialog.run()
     if response == gtk.RESPONSE_OK:
         textBuffer = gtk.TextBuffer()
         textBuffer.set_text(dialog.get_filename())
         textview.set_buffer(textBuffer)
     dialog.destroy()
Exemplo n.º 2
0
 def __init__(self):
     gtk.TextView.__init__(self)
     self.tabla = gtk.TextTagTable()
     self.buffer = gtk.TextBuffer(self.tabla)
     self.buffer.connect_after("insert-text", self.bufferInsert)
     self.set_buffer(self.buffer)
     self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
     self.set_editable(False)
     self.set_cursor_visible(False)
Exemplo n.º 3
0
def run_edit_dialog(text, finish_hook=None, title=None):
    """Run a dialog for editing some text."""
    parent_window = get_dialog_parent()
    dialog = gtk.Dialog(title,
                        buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT),
                        parent=parent_window)

    dialog.set_border_width(DIALOG_SUB_PADDING)

    scrolled_window = gtk.ScrolledWindow()
    scrolled_window.set_border_width(DIALOG_SUB_PADDING)
    scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)

    text_buffer = gtk.TextBuffer()
    text_buffer.set_text(text)
    text_view = gtk.TextView()
    text_view.set_editable(True)
    text_view.set_wrap_mode(gtk.WRAP_NONE)
    text_view.set_buffer(text_buffer)
    text_view.show()

    scrolled_window.add_with_viewport(text_view)
    scrolled_window.show()

    dialog.vbox.pack_start(scrolled_window, expand=True, fill=True,
                           padding=0)
    get_text = lambda: text_buffer.get_text(text_buffer.get_start_iter(),
                                            text_buffer.get_end_iter())

    max_size = rose.config_editor.SIZE_MACRO_DIALOG_MAX
    # defines the minimum acceptable size for the edit dialog
    min_size = DIALOG_SIZE_PROCESS

    # hacky solution to get "true" size for dialog
    dialog.show()
    start_size = dialog.size_request()
    scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    end_size = dialog.size_request()
    my_size = (max([start_size[0], end_size[0], min_size[0]]) + 20,
               max([start_size[1], end_size[1], min_size[1]]) + 20)
    new_size = [-1, -1]
    for i in [0, 1]:
        new_size[i] = min([my_size[i], max_size[i]])
    dialog.set_size_request(*new_size)

    if finish_hook is None:
        response = dialog.run()
        if response == gtk.RESPONSE_ACCEPT:
            text = get_text().strip()
            dialog.destroy()
            return text
        dialog.destroy()
    else:
        finish_func = lambda: finish_hook(get_text().strip())
        dialog.connect("response", _handle_edit_dialog_response, finish_func)
        dialog.show()
Exemplo n.º 4
0
    def __init__(self):
        self._is_unset = True
        gtk.TextView.__init__(self)
        self.props.data_type = str
        ValidatableProxyWidgetMixin.__init__(self)

        self._textbuffer = gtk.TextBuffer()
        self._textbuffer.connect('changed', self._on_textbuffer__changed)
        self.set_buffer(self._textbuffer)
Exemplo n.º 5
0
 def __init__(self,
              font=application_font,
              lines=1,
              multiline=0,
              password=0,
              **kwds):
     self._multiline = multiline
     lm, tm, rm, bm = gtk_margins
     if multiline:
         gtk_textbuffer = gtk.TextBuffer()
         gtk_textview = gtk.TextView(gtk_textbuffer)
         #gtk_textview.set_accepts_tab(False) #^%$#^%$!!! moves the focus itself.
         #self._gtk_connect(gtk_textview, 'key-press-event', self._gtk_key_press_event)
         self._gtk_connect(gtk_textbuffer, 'changed', self._gtk_changed)
         gtk_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
         gtk_alignment.set_padding(tm, bm, lm, rm)
         gtk_alignment.add(gtk_textview)
         gtk_box = gtk.EventBox()
         gtk_box.add(gtk_alignment)
         gtk_box.modify_bg(gtk.STATE_NORMAL,
                           gtk_textview.style.base[gtk.STATE_NORMAL])
         gtk_frame = gtk.Frame()
         gtk_frame.set_shadow_type(gtk.SHADOW_IN)
         gtk_frame.add(gtk_box)
         self._gtk_textbuffer = gtk_textbuffer
         gtk_text_widget = gtk_textview
         gtk_outer = gtk_frame
     else:
         gtk_entry = gtk.Entry()
         #self._gtk_connect(gtk_entry, 'key-press-event', self._gtk_key_press_event)
         self._gtk_connect(gtk_entry, 'changed', self._gtk_changed)
         self._gtk_entry = gtk_entry
         gtk_text_widget = gtk_entry
         gtk_outer = gtk_entry
     self._gtk_text_widget = gtk_text_widget
     self._font = font
     gtk_text_widget.modify_font(font._pango_description)
     self._vertical_padding = tm + 2 * gtk_outer.style.ythickness + bm
     height = self._vertical_padding + lines * font.text_size("X")[1]
     gtk_outer.set_size_request(-1, height)
     self._password = password
     if password:
         if not multiline:
             self._gtk_entry.set_visibility(0)
             self._gtk_entry.set_invisible_char("*")
         else:
             raise ValueError(
                 "The password option is not supported for multiline"
                 " TextFields on this platform")
     gtk_outer.show_all()
     GTextField.__init__(self,
                         _gtk_outer=gtk_outer,
                         _gtk_title=gtk_text_widget,
                         _gtk_focus=gtk_text_widget,
                         _gtk_input=gtk_text_widget,
                         multiline=multiline,
                         **kwds)
Exemplo n.º 6
0
 def on_active_vocab(self, widget):
     # creamos un textbuffer para el resultado
     text_buffer = gtk.TextBuffer()
     #cargamos los datos del vocabulario
     voca = mdl.vocabularioTotal()
     for j in voca:
         text_buffer.set_text(str(j) + '\n')
     ## mostramos el buffer en el text view
     self.textview1.set_buffer(text_buffer)
Exemplo n.º 7
0
	def do_generate(self):
		howmany = int(self.glade.get_widget('howmany').get_text())
		what = self.what[self.glade.get_widget('what').get_active()]
		start_with = 'yes' if self.glade.get_widget('start_with').get_active() else 'no'
		lipsum = pypsum.get_lipsum(howmany, what, start_with)
		buf = gtk.TextBuffer()
		buf.set_text(lipsum[0])
		self.glade.get_widget('lipsum').set_buffer(buf)
		self.glade.get_widget('generated').set_text(lipsum[1])
Exemplo n.º 8
0
    def __init__(self, activity):
        gtk.VBox.__init__(self)

        self.activity = activity

        mov_box = gtk.HBox()

        # Add movie window
        self.movie_window = gtk.DrawingArea()
        self.movie_window_preview = gtk.DrawingArea()
        mov_box.pack_start(self.movie_window)
        mov_box.pack_start(self.movie_window_preview)

        self.pack_start(mov_box)
        # Add Chat section
        ##################

        # Chat expander allows chat to be hidden/shown
        chat_expander = gtk.Expander(_("Chat"))
        chat_expander.set_expanded(True)
        self.pack_start(chat_expander, False)

        chat_holder = gtk.VBox()
        chat_expander.add(chat_holder)

        # Create entry and history view for chat
        chat_history = gtk.ScrolledWindow()
        chat_history.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)

        self.chat_text = gtk.TextBuffer()
        self.text_view = gtk.TextView(self.chat_text)
        self.text_view.set_editable(False)
        self.text_view.set_size_request(-1, 200)

        chat_history.add(self.text_view)

        # Send button to complete feel of a chat program
        self.chat_entry = gtk.Entry()
        self.chat_entry.connect("activate", self.send_chat)
        send_but = gtk.Button(_("Send"))
        send_but.connect("clicked", self.send_chat)

        # Wrap button and entry in hbox so they are on the same line
        chat_entry_hbox = gtk.HBox()
        chat_entry_hbox.pack_start(self.chat_entry)
        chat_entry_hbox.pack_end(send_but, False)

        # Add chat history and entry to expander
        chat_holder.pack_start(chat_history)
        chat_holder.pack_start(chat_entry_hbox, False)

        # Show gui
        self.build_toolbars()
        self.show_all()

        #scroll to bottom
        self.text_view.scroll_to_iter(self.chat_text.get_end_iter(), 0.1)
Exemplo n.º 9
0
	def set_layout(self):
		self.listore_model = ListoreModel()
		self.modelsort = gtk.TreeModelSort(self.listore_model)
		self.notify_store = Notify_Store(self.modelsort)
		self.text_buffer = gtk.TextBuffer()
		self.text_view = gtk.TextView(buffer=self.text_buffer)
		self.text_view.set_editable(False)
		self.text_view.set_justification(gtk.JUSTIFY_LEFT)
		hpanel = gtk.HPaned()
Exemplo n.º 10
0
    def gui_setup(self):
        pbox = gtk.VBox(False, 0)
        self.set_default_size(*self.default_size)
        menu_items = (
            ("/File/Import Text", "<control>I", self.file_import, 0, None),
            ("/File/Export Text", "<control>E", self.file_export, 0, None),
            ("/File/Revert to Saved Source", None, self.load_source, 0, None),
            ("/File/Revert to Disassembly", None, self.load_disassemble, 0,
             None),
            ("/File/Load from TAUCS", None, self.load_taucs, 0, None),
            ("/File/Assemble and Save", "<control>S", self.file_save, 0, None),
            ("/File/Save Source Code", "<shift><control>S",
             self.do_save_source, 0, None),
            ("/Edit/Edit in External Text Editor", "<control>G",
             self.edit_external, 0, None),
            ("/Edit/Purge Source", None, self.purge, 0, None),
            #("/Edit/Check Syntax", "<control>T",
            #     self.edit_syntax, 0, None),

            #("/Edit/Copy", "<control>C", self.edit_copy, 0, None),
            #("/Edit/Paste","<control>V", self.edit_paste, 0, None),
        )
        accel = gtk.AccelGroup()
        ifc = gtk.ItemFactory(gtk.MenuBar, "<main>", accel)
        self.add_accel_group(accel)
        ifc.create_items(menu_items)
        self.menu_bar = ifc.get_widget("<main>")
        pbox.pack_start(self.menu_bar, False, True, 0)

        self.text_buf = gtk.TextBuffer()
        self.text_buf.set_text(" Nothing Loaded ".center(78, ';'))
        self.text_view = gtk.TextView()
        self.text_view.set_buffer(self.text_buf)
        self.text_view.set_wrap_mode(gtk.WRAP_CHAR)
        fontdesc = pango.FontDescription("monospace 10")
        self.text_view.modify_font(fontdesc)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.text_view)
        pbox.pack_start(sw, True, True, 0)
        hbox = gtk.HBox(False, 0)
        hbox.pack_start(gtk.Label("Status:"), False, True, 0)
        self.asm_status = gtk.Entry()
        self.asm_status.set_editable(False)
        self.asm_status.set_text("Disassembling binary... ")
        hbox.pack_start(self.asm_status, True, True, 0)
        self.auto_assemble = gtk.ToggleButton("Auto-Assemble")
        self.auto_assemble.set_active(True)
        hbox.pack_start(self.auto_assemble, False, True, 0)
        self.save_source = gtk.ToggleButton("Auto-save Source")
        self.save_source.set_active(True)
        hbox.pack_start(self.save_source, False, True, 0)
        pbox.pack_start(hbox, False, True, 0)
        self.add(pbox)
        self.assembler = None
        self.cycle_check = False
Exemplo n.º 11
0
 def sel_changed(self, selection, *args):
     treemodel, row = selection.get_selected()
     changed_plugin_name = treemodel.get(row, 1)
     if not row:
         return
     changed_plugin = self.plugin_manager.get_plugin(*changed_plugin_name)
     plugin_desc = self.wtree.get_widget("plugin_desc")
     text_buffer = gtk.TextBuffer()
     text_buffer.set_text(changed_plugin.desc)
     plugin_desc.set_buffer(text_buffer)
Exemplo n.º 12
0
    def __log(self):
        buffer = gtk.TextBuffer()

        iter = buffer.get_iter_at_offset(0)
        buffer.insert(iter, "sadfs")
        textView = gtk.TextView(buffer)
        textView.set_size_request(-1, 120)

        textView.show_all()
        return textView
Exemplo n.º 13
0
	def make_tbox(auto,text):
		string=gtk.TextBuffer()
		string.set_text(text)
		#creats a text box
		txt=gtk.TextView(string)
		txt.set_cursor_visible(True)
		#function for editing the text
		txt.set_editable(True)
		txt.show()			
		return txt
Exemplo n.º 14
0
 def create_text_buffer():
     text_buffer = gtk.TextBuffer()
     text_buffer.create_tag("default", font="Monospace 10")
     text_buffer.create_tag("set_warning_color", foreground="orange")
     text_buffer.create_tag("set_error_color", foreground="red")
     text_buffer.create_tag("set_debug_color", foreground="#00baf8")
     text_buffer.create_tag("set_info_color", foreground="#39af57")
     text_buffer.create_tag("set_gray_text", foreground="#93959a")
     text_buffer.create_tag("set_white_text", foreground="#ffffff")
     return text_buffer
Exemplo n.º 15
0
        def get_source_view():
            source = gtk.ScrolledWindow()
            source.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

            view = gtk.TextView()
            self.code = gtk.TextBuffer()
            view.set_buffer(self.code)
            source.add(view)

            return source
Exemplo n.º 16
0
    def __init__(self, core, window, buffer=None):
        if not buffer:
            buffer = gtk.TextBuffer(tag_table)

        gtk.TextView.__init__(self, buffer)
        self.core = core
        self.events = core.events
        self.win = window

        self.set_size_request(0, -1)

        self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
        self.set_editable(False)
        self.set_cursor_visible(False)

        self.set_property("left-margin", 3)
        self.set_property("right-margin", 3)

        self.linking = set()

        self.add_events(gtk.gdk.POINTER_MOTION_HINT_MASK)
        self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)

        self.connect('populate-popup', TextOutput.popup)
        self.connect('motion-notify-event', TextOutput.hover)
        self.connect('button-press-event', TextOutput.mousedown)
        self.connect('button-release-event', TextOutput.mouseup)
        self.connect_after('button-release-event', lambda *a: True)
        self.connect('leave-notify-event', TextOutput.clear_hover)

        self.hover_coords = 0, 0

        self.autoscroll = True
        self._scrolling = False
        self.scroller = gtk.Adjustment()

        def setup_scroll(self, _adj, vadj):
            self.scroller = vadj

            if vadj:

                def set_scroll(adj):
                    self.autoscroll = adj.value + adj.page_size >= adj.upper

                vadj.connect("value-changed", set_scroll)

        self.connect("set-scroll-adjustments", setup_scroll)
        self.connect("size-allocate", TextOutput.scroll)

        def set_cursor(widget):
            self.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(None)

        self.connect("realize", set_cursor)

        style_me(self, "view")
Exemplo n.º 17
0
    def launch(self, doDebug=None):
        self.doDebug = doDebug
        if self.doDebug:
            print "initializing smolt module"

        self.vbox = gtk.VBox()
        self.vbox.set_size_request(400, 200)

        msg = (_("Hardware Profile"))

        title_pix = functions.imageFromFile("smolt.png")

        internalVBox = gtk.VBox()
        internalVBox.set_border_width(10)
        internalVBox.set_spacing(5)

        textBuffer = gtk.TextBuffer()
        textView = gtk.TextView()
        textView.set_editable(False)
        textSW = gtk.ScrolledWindow()
        textSW.set_shadow_type(gtk.SHADOW_IN)
        textSW.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        textSW.add(textView)

        label = gtk.Label(
            _("Smolt is a hardware profiler for The Fedora "
              "Project.  Submitting your profile is a great way to give back "
              "to the community as this information is used to help focus our"
              " efforts on popular hardware and platforms.  Submissions are "
              "anonymous.  Sending your profile will enable a monthly update.")
        )

        label.set_line_wrap(True)
        label.set_alignment(0.0, 0.5)
        label.set_size_request(500, -1)
        internalVBox.pack_start(label, False, True)

        iter = textBuffer.get_iter_at_offset(0)

        for line in os.popen('/usr/bin/smoltSendProfile -p', 'r'):
            textBuffer.insert(iter, line)

        textView.set_buffer(textBuffer)

        self.okButton = gtk.RadioButton(None, (_("_Send Profile")))
        self.noButton = gtk.RadioButton(self.okButton,
                                        (_("D_o not send profile")))
        self.noButton.set_active(True)

        internalVBox.pack_start(textSW, True)
        internalVBox.pack_start(self.okButton, False)
        internalVBox.pack_start(self.noButton, False)

        self.vbox.pack_start(internalVBox, True, 5)
        return self.vbox, title_pix, msg
Exemplo n.º 18
0
    def __init__(self, server):
        gtk.StatusIcon.__init__(self)
        self.server = server
        self.window = None
        menu = '''
            <ui>
              <menubar name="Menubar">
                <menu action="Menu">
                  <menuitem action="Reload"/>
                  <menuitem action="Registrar"/>
                  <separator/>
                  <menuitem action="About"/>
                  <menuitem action="Quit"/>
                </menu>
              </menubar>
            </ui>
          '''
        actions = [('Menu', None, 'Menu'), ('Reload', None, 'Reload'),
                   ('Registrar', None, 'Show Registrar Data', None, None,
                    self.show_registrar_data),
                   ('About', gtk.STOCK_ABOUT, '_About...', None,
                    'About Automaton', self.on_about),
                   ('Quit', None, '_Quit', None, None, self.on_quit)]
        agrp = gtk.ActionGroup('Actions')
        agrp.add_actions(actions)
        self.manager = gtk.UIManager()
        self.manager.insert_action_group(agrp, 0)
        self.manager.add_ui_from_string(menu)
        self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent

        # Dynamically build the reload menu
        if self.server is not None:
            rldmenu = gtk.Menu()
            rld = self.manager.get_widget('/Menubar/Menu/Reload')
            for plugin in sorted(self.server.loaded_plugins):
                item = gtk.MenuItem(plugin)
                item.show()
                item.connect("activate", self.on_reload)
                rldmenu.append(item)
            if len(rldmenu.get_children()) > 0:
                rld.set_submenu(rldmenu)

        self.command_log = gtk.TextBuffer()
        self.command_log_lock = threading.Lock()

        self.set_from_stock(gtk.STOCK_FIND)
        self.set_visible(True)
        self.connect('activate', self.on_command_activate)
        self.connect('popup-menu', self.on_popup_menu)

        self.build_command_window()

        self.window_active = False
        self.window_display_position = self.window.get_position()
        self.window_display_size = self.window.get_size()
Exemplo n.º 19
0
	def __init__(self, datalist = None):
		self.game_time=900
		self.preformat_data(datalist)
		self.password = "******"
		self.path= "data/.pytypespeed.dat" 
		self.gladefile = "data/pytypespeed.glade"
		self.timeout = False
		self.timer_id = None
		self.seconds = 0
		self.wTree = gtk.glade.XML(self.gladefile,"winTypeSpeed")
		self.dic = { 
		"on_new_activate" : self.new_game, 
		"on_export_activate" : self.export_score,
		"on_quit_activate" : self.quit_pytypespeed, 
		"on_entry_test_key_press_event" : self.entry_test_key_press,
		"on_winTypeSpeed_destroy" : self.quit_pytypespeed,
		}
		self.wTree.signal_autoconnect(self.dic)
		
		self.main_window = self.wTree.get_widget('winTypeSpeed')
		self.entry_data = self.wTree.get_widget('entry_data')
		self.entry_test = self.wTree.get_widget('entry_test')
		self.statusbar = self.wTree.get_widget("statusbar1")
		
		
		self.tbuff1 = gtk.TextBuffer(table=None)
		self.tbuff2 = gtk.TextBuffer(table=None)
		#self.entry_name.set_text(self.name.capitalize())
		self.entry_data.set_buffer(self.tbuff1)
		self.entry_test.set_buffer(self.tbuff2)
		self.tbuff1.set_text("")
		self.tag_completed = self.tbuff1.create_tag("completed")
		self.tag_completed.set_property("foreground", "blue")
		
		self.entry_data.modify_font(pango.FontDescription("Meera 15"))
		self.entry_test.modify_font(pango.FontDescription("Meera 15"))
		self.count, self.score, self.order = 0, 0, 0
		self.words=len(self.rstring.split())
		self.main_window.maximize()
		self.entry_test.set_sensitive(False)
		self.read_score()
		self.new_game()