python类TextView()的实例源码

RemarkableWindow.py 文件源码 项目:Remarkable 作者: jamiemcg 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def on_menuitem_custom_activate(self, widget):
        self.custom_window = Gtk.Window()
        self.custom_window.set_default_size(640, 480)
        self.custom_window.set_position(Gtk.WindowPosition.CENTER)
        self.custom_window.set_title("Custom CSS")

        self.custom_vbox = Gtk.VBox()
        self.custom_scroller = Gtk.ScrolledWindow()
        self.custom_button = Gtk.Button("Apply")
        self.custom_vbox.pack_end(self.custom_button, False, False, 0)
        self.custom_text_view = Gtk.TextView()
        self.custom_text_buffer = Gtk.TextBuffer()
        self.custom_text_buffer.set_text(self.custom_css)
        self.custom_text_view.set_buffer(self.custom_text_buffer)
        self.custom_scroller.add(self.custom_text_view)
        self.custom_vbox.pack_start(self.custom_scroller, True, True, 0)
        self.custom_window.add(self.custom_vbox)
        self.custom_window.show_all()
        self.custom_button.connect("clicked", self.apply_custom_css, self.custom_window, self.custom_text_buffer)
gui_text_editor.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def create_textview(self):
        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.set_hexpand(True)
        scrolledwindow.set_vexpand(True)
        self.grid.attach(scrolledwindow, 0, 1, 3, 1)

        self.textview = Gtk.TextView()
        self.textbuffer = self.textview.get_buffer()
        self.textbuffer.set_text("This is some text inside of a Gtk.TextView. "
            + "Select text and click one of the buttons 'bold', 'italic', "
            + "or 'underline' to modify the text accordingly.")
        scrolledwindow.add(self.textview)

        self.tag_bold = self.textbuffer.create_tag("bold",
            weight=Pango.Weight.BOLD)
        self.tag_italic = self.textbuffer.create_tag("italic",
            style=Pango.Style.ITALIC)
        self.tag_underline = self.textbuffer.create_tag("underline",
            underline=Pango.Underline.SINGLE)
        self.tag_found = self.textbuffer.create_tag("found",
            background="yellow")
impressWriter.py 文件源码 项目:impress-writer 作者: CSEC-NITH 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def create_textview(self):
        self.vbox_left1.add(self.text_grid)
        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.set_hexpand(True)
        scrolledwindow.set_vexpand(True)
        self.text_grid.attach(scrolledwindow, 0, 1, 3, 1)

        self.textview = Gtk.TextView()

        spellchecker = SpellChecker(self.textview,locale.getdefaultlocale()[0])

        self.textbuffer = self.textview.get_buffer()

        scrolledwindow.add(self.textview)

        self.tag_bold = self.textbuffer.create_tag("bold",
                                                   weight=Pango.Weight.BOLD)
        self.tag_italic = self.textbuffer.create_tag("italic",
                                                     style=Pango.Style.ITALIC)
        self.tag_underline = self.textbuffer.create_tag("underline",
                                                        underline=Pango.Underline.SINGLE)
        self.tag_found = self.textbuffer.create_tag("found",
                                                    background="yellow")
        self.textview.connect("key_release_event",self.on_key_release)
widget.py 文件源码 项目:MTodo 作者: mortezaipo 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, name: str, placeholder: str, multi_line: bool):
        """Initialize Input class"""
        self._name = name
        self._placeholder = placeholder
        self._multi_line = multi_line
        if self._multi_line is True:
            self._widget = Gtk.TextView()
            self._widget.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
            self._widget.set_size_request(400, 219)
            #placeholder
            self._widget.connect("focus-in-event", self._in_focus)
            self._widget.connect("focus-out-event", self._out_focus)
            self._widget.get_buffer().set_text(self._placeholder)
        else:
            self._widget = Gtk.Entry()
            self._widget.unset_state_flags(Gtk.StateFlags.FOCUSED)
            self._widget.set_placeholder_text(self._placeholder)

        self._widget.set_name(self._name)
main.py 文件源码 项目:pytimetrack 作者: fhackerz 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.TextView.__init__(self)
        self._extended_footer = False
        self._footer_mark = None
        self._update_pending = False
        self._footer_update_pending = False
        self.set_up_tabs()
        self.set_up_tags()
        self.connect('notify::timelog', self.queue_update)
        self.connect('notify::date', self.queue_update)
        self.connect('notify::showing-today', self.queue_update)
        self.connect('notify::detail-level', self.queue_update)
        self.connect('notify::time-range', self.queue_update)
        self.connect('notify::hours', self.queue_footer_update)
        self.connect('notify::office-hours', self.queue_footer_update)
        self.connect('notify::current-task', self.queue_footer_update)
        self.connect('notify::now', self.queue_footer_update)
        self.connect('notify::filter-text', self.queue_update)
table.py 文件源码 项目:MTTT 作者: roxana-lafuente 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def create_cell(self, text_line_type, text_view_type, row_index, editable):
        cell = Gtk.TextView()
        cell.set_editable(editable)
        cell.set_cursor_visible(editable)
        cellTextBuffer = cell.get_buffer()
        index = row_index + self.tables_content[self.table_index]
        text = textwrap.fill(self.tables_content[text_line_type][index].rstrip('\n'), width=40)
        cellTextBuffer.set_text(text)
        cellTextBuffer.create_tag("#F8CBCB",background="#F8CBCB")
        cellTextBuffer.create_tag("#A6F3A6",background="#A6F3A6")
        self.tables_content[text_view_type][index] = cell
        if self.table_type == "translation_table":
            cellTextBuffer.connect("changed", self.cell_in_translation_table_changed, index)
            cell.connect("button-press-event", self.cell_in_translation_table_is_being_focused, index)
            if index in self.translation_reference_text_TextViews_modified_flag:
                self.tables_content[self.reference_text_views][index].override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.7, 249, 249, 240))

        cell.set_right_margin(20)
        cell.show()
        self.table.attach(
        cell,
        text_line_type + 1,
        text_line_type + 2,
        row_index + 1,
        row_index + 2)
serverwindow.py 文件源码 项目:funky 作者: giannitedesco 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self):
        super(ServerWindow, self).__init__(\
                orientation = Gtk.Orientation.VERTICAL,
                spacing = 6)

        self.entry = CmdEntry()
        self.entry.connect('send', self.__cb)

        self.text = Gtk.TextView()
        self.text.set_editable(False)
        self.text.set_cursor_visible(False)
        self.text.set_wrap_mode(Gtk.WrapMode.WORD)
        self.__setup_tags(self.text.get_buffer())
        scr = Gtk.ScrolledWindow()
        scr.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scr.add(self.text)

        scr.set_can_focus(False)
        self.text.set_can_focus(False)

        self.pack_start(scr, True, True, 0)
        self.pack_start(self.entry, False, True, 0)
bracer.py 文件源码 项目:bracer 作者: deikatsuo 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def do_load(self, workbench):
        print('Builder Workbench Addin: Load Bracer plugin workbench')

        editor = workbench.get_perspective_by_name('editor')
        dock_pane = Ide.EditorPerspective.get_utilities(editor)

        dock_widget = Dazzle.DockWidget(title=_('Rust Docs'),
                                        icon_name='accessories-dictionary-symbolic',
                                        visible=True,
                                        expand=False)

        Bracer.dock_widget = dock_widget

        if Bracer.settings.get_boolean('prefs-documentation'):
            if Bracer.settings.get_boolean('prefs-markdown'):
                Bracer._MARKDOWN_CSS = Bracer.get_data('resources/markdown.css')
                Bracer._HL_GITHUB_CSS = Bracer.get_data('resources/github.css')
                Bracer._MARKED_JS = Bracer.get_data('resources/marked.js')
                Bracer._HL_JS = Bracer.get_data('resources/hljs.js')
                Bracer._MARKDOWN_VIEW_JS = Bracer.get_data('resources/markdown-view.js')

                webview = WebKit2.WebView(visible=True, expand=True)
                Bracer.dock_webview = webview
                settings = webview.get_settings()
                settings.enable_html5_local_storage = False
                Bracer.dock_widget.add(Bracer.dock_webview)
                Ide.LayoutPane.add(dock_pane, Bracer.dock_widget)
            else:
                dock_text_widget = Gtk.TextView(visible=True, expand=True)
                Bracer.dock_text_widget = dock_text_widget
                scrolled = Gtk.ScrolledWindow(visible=True)
                scrolled.add(Bracer.dock_text_widget)
                Bracer.dock_widget.add(scrolled)
                Ide.LayoutPane.add(dock_pane, Bracer.dock_widget)
reportbug.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, parent, error_text):
        Gtk.Dialog.__init__(self, _("Make bug report"), parent,
                buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT))
        self.m_error_text = error_text
        self.add_button(_("_Send"), RESPONSE_SEND)
        self.set_default_size(400, 400)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        l = Gtk.Label(_("Information about the version of GNU Solfege, your operating system and Python version, and the Python traceback (error message) will be sent to the crash database. Your email will not be published or shared, but we might contact you by email if we have further questions about your crash report."))
        l.set_line_wrap(True)
        l.show()
        self.vbox.pack_start(l, False, False, 0)
        self.g_email = Gtk.Entry()
        self.vbox.pack_start(
            gu.hig_label_widget(_("_Email:"), self.g_email, sizegroup),
            False, False, 0)
        self.g_email.set_text(cfg.get_string('user/email'))
        # 140 is max in the solfege.org database
        self.g_description = Gtk.Entry()
        self.g_description.set_max_length(140)
        self.vbox.pack_start(
            gu.hig_label_widget(_("S_hort description:"), self.g_description,
                     sizegroup), False, False, 0)
        label = Gtk.Label(label=_("_Describe how to produce the error message:"))
        label.set_use_underline(True)
        label.set_alignment(0.0, 0.5)
        self.vbox.pack_start(label, False, False, 0)
        self.g_tw = Gtk.TextView()
        self.g_tw.set_wrap_mode(Gtk.WrapMode.WORD)
        self.g_tw.set_border_width(10)
        label.set_mnemonic_widget(self.g_tw)
        self.vbox.pack_start(self.g_tw, True, True, 0)
        self.show_all()
gu.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.ScrolledWindow.__init__(self)
        self.g_textbuffer = Gtk.TextBuffer()
        self.g_textbuffer.create_tag('h1', weight=Pango.Weight.BOLD,
            size=16*Pango.SCALE)
        self.g_textview = Gtk.TextView(buffer=self.g_textbuffer)
        self.add(self.g_textview)
mpd-test.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.Window.__init__(self)
        self.connect('destroy', self.on_quit)
        self.vbox = vbox = Gtk.VBox()
        vbox.show()
        self.add(vbox)
        self.g_text = Gtk.TextView()
        self.g_text.set_size_request(-1, 100)
        self.g_text.show()
        self.g_text.set_editable(True)
        try:
            s = open(musicfile, "r").read()
        except IOError, e:
            s = r"\staff{c' d' e'}"
        self.m_buf = self.g_text.get_buffer()
        self.m_buf.insert(self.m_buf.get_end_iter(), s)
        vbox.pack_start(self.g_text, True, True, 0)
        self.g_displayer = MusicDisplayer()
        self.g_displayer.set_size_request(200, 200)
        self.g_displayer.show()
        self.vbox.pack_start(self.g_displayer, True, True, 0)
        gu.bButton(vbox, "Parse", self.on_parse)
        gu.bButton(vbox, "Display", self.on_display)
        gu.bButton(vbox, "Display first notes", self.on_display_first_notes)
        gu.bButton(vbox, "Play", self.on_play)
        gu.bButton(vbox, "Play first", self.on_play_first)
search_dialog.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, main, title='Search results'):
        super(SearchDialog,self).__init__(title, main.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_OK,Gtk.ResponseType.ACCEPT))

        # the cancel button
        self.butt_cancel = self.action_area.get_children()[0]
        self.butt_cancel.connect("clicked", lambda x: self.destroy())

        # Positions
        self.resize(400, 400)
        self.set_position(Gtk.WindowPosition.CENTER)
        ui.gtk3.common.set_bokken_icon(self)

        # Log TextView
        #################################################################
        self.output_text = Gtk.TextView(buffer=None)
        self.output_text.set_wrap_mode(Gtk.WrapMode.NONE)
        self.output_text.set_editable(False)
        self.output_buffer = self.output_text.get_buffer()

        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
        self.scrolled_window.is_visible = True

        # Add Textview to Scrolled Window
        self.scrolled_window.add_with_viewport(self.output_text)

        #self.vbox.pack_start(self.output_text, True, True, 0)
        self.vbox.pack_start(self.scrolled_window, True, True, 0)
        self.show_all()
comments_dialog.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self, title='Add comment'):
        super(CommentsDialog,self).__init__(title, None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))

        # the cancel button
        self.butt_cancel = self.action_area.get_children()[1]
        self.butt_cancel.connect("clicked", lambda x: self.destroy())

        # Positions
        self.resize(400, 200)
        self.set_position(Gtk.WindowPosition.CENTER)
        ui.gtk3.common.set_bokken_icon(self)

        # Log TextView
        #################################################################
        self.input_text = Gtk.TextView(buffer=None)
        self.input_text.set_wrap_mode(Gtk.WrapMode.NONE)
        self.input_text.set_left_margin(10)
        self.input_buffer = self.input_text.get_buffer()

        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolled_window.is_visible = True

        # Add Textview to Scrolled Window
        self.scrolled_window.add_with_viewport(self.input_text)

        #self.vbox.pack_start(self.input_text, True, True, 0)
        self.vbox.pack_start(self.scrolled_window, True, True, 0)
        self.show_all()
main.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, parent=None,
                 title='', description='', long_description=''):
        Gtk.Window.__init__(self, title=title)
        self.set_parent(parent)
        self.set_transient_for(parent)
        self.set_destroy_with_parent(False)
        self.set_default_size(600, 500)
        self.vbox = Gtk.VBox(spacing=0)
        self.add(self.vbox)
        self.text_buffer = Gtk.TextBuffer()
        self.text_buffer.insert_at_cursor(description)
        self.text_buffer.insert_at_cursor(
            '\n\n'
            + '############################################################'
            + '\n')
        self.text_buffer.insert_at_cursor(
            'Complete file implementing the input method follows here:\n')
        self.text_buffer.insert_at_cursor(
            '############################################################'
            + '\n')
        self.text_buffer.insert_at_cursor(long_description)
        self.text_view = Gtk.TextView()
        self.text_view.set_buffer(self.text_buffer)
        self.text_view.set_editable(False)
        self.text_view.set_cursor_visible(False)
        self.text_view.set_justification(Gtk.Justification.LEFT)
        self.text_view.set_wrap_mode(Gtk.WrapMode.WORD)
        self.scrolledwindow = Gtk.ScrolledWindow()
        self.scrolledwindow.set_hexpand(True)
        self.scrolledwindow.set_vexpand(True)
        self.scrolledwindow.add(self.text_view)
        self.vbox.pack_start(self.scrolledwindow, True, True, 0)
        self.close_button = Gtk.Button(stock=Gtk.STOCK_CLOSE)
        self.close_button.connect("clicked", self.on_close_button_clicked)
        self.hbox = Gtk.HBox(spacing=0)
        self.hbox.pack_end(self.close_button, False, False, 0)
        self.vbox.pack_start(self.hbox, False, False, 5)
gui_text_editor.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.Window.__init__(self, title="TextView Example")

        self.set_default_size(-1, 350)

        self.grid = Gtk.Grid()
        self.add(self.grid)

        self.create_textview()
        self.create_toolbar()
        self.create_buttons()
gracer.py 文件源码 项目:gracer 作者: isamert 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def do_create_configure_widget(self):
        table = Gtk.Table(3, 2, Gtk.true())
        table.set_row_spacings(5)
        table.set_col_spacings(5)

        lbl_racerpath = Gtk.Label("Racer path: ")
        lbl_rustsrc   = Gtk.Label("Rust source path: ")

        self.txt_racerpath = Gtk.TextView()
        self.txt_rustsrc   = Gtk.TextView()

        rust_src_path = self.racer.get_rust_src_path()
        racer_path = self.racer.get_racer_path()

        self.txt_racerpath.get_buffer().set_text(racer_path)
        self.txt_rustsrc.get_buffer().set_text(rust_src_path)

        btn_save = Gtk.Button("Save")
        btn_save.connect("clicked", self.on_btn_save_clicked)

        table.attach(lbl_racerpath, 0, 1, 0, 1)
        table.attach(lbl_rustsrc, 0, 1, 1, 2)
        table.attach(self.txt_racerpath, 1, 2, 0, 1)
        table.attach(self.txt_rustsrc, 1, 2, 1, 2)
        table.attach(btn_save, 0, 2, 2, 3)

        return table
main.py 文件源码 项目:pytimetrack 作者: fhackerz 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.TextView.__init__(self)
        self._update_pending = False
        self._subject = ''
        self.connect('notify::timelog', self.queue_update)
        self.connect('notify::name', self.update_subject)
        self.connect('notify::date', self.queue_update)
        self.connect('notify::time-range', self.queue_update)
        self.connect('notify::report-style', self.queue_update)
        self.connect('notify::visible', self.queue_update)
        self.connect('notify::recipient', self.update_already_sent_indication)
        self.bind_property('body', self.get_buffer(), 'text',
                           GObject.BindingFlags.BIDIRECTIONAL)
        if (Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION) < (3, 16):
            # Seems like a bug on GTK+ 3.10 where editing text doesn't emit the
            # notify::text signal, and so property bindings don't get updated.
            # I don't have the patience to dig through bugzilla to find when
            # the bug was fixed, or to test GTK+ 3.12/3.14, so I'll just apply
            # the workaround for all GTK+ versions older than the one I
            # currently use, which doesn't have the bug.  The workaround should
            # be harmless.
            self.get_buffer().connect('changed', self.buffer_changed_workaround)
        # GTK+ versions before 3.16 did not have a 'monospace' property.
        # GTK+ themes other than Adwaita ignore the 'monospace' property and
        # use a proportional font for text widgets.
        self.override_font(Pango.FontDescription.from_string("Monospace"))

        filename = Settings().get_report_log_file()
        self.record = ReportRecord(filename)
table.py 文件源码 项目:MTTT 作者: roxana-lafuente 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def create_search_button (self, text, line_index):
        search_button = Gtk.Button()
        self.search_buttons_array.append(search_button)
        cell = Gtk.TextView()
        cell.set_wrap_mode(True)
        cellTextBuffer = cell.get_buffer()
        cellTextBuffer.set_text(text)
        cell.set_right_margin(20)
        cell.set_wrap_mode(2)#2 == Gtk.WRAP_WORD
        cell.show()
        search_button.add(cell)
        search_button.show()
        search_button.connect("clicked", self._search_button_action, line_index)
        button_y_coordinate = len(self.search_buttons_array) -1
        self.search_buttons_table.attach(search_button, 0, 0+1, button_y_coordinate, button_y_coordinate+1)
table.py 文件源码 项目:MTTT 作者: roxana-lafuente 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _clean_table(self):
        children = self.table.get_children();
        for element in children:
            #remove all Gtk.Label and Gtk.TextView objects
            if isinstance(element,Gtk.TextView) or isinstance(element,Gtk.Label):
                self.table.remove(element)
        #re-attach the source and target labels
        if self.monolingual:
            source_label = Gtk.Label("Unedited MT")
            self.table.attach(source_label, 1, 1+1, 0, 1+0)
            source_label.show()

            target_label = Gtk.Label("Edited MT")
            self.table.attach(target_label, 3, 3+1, 0, 1+0)
            target_label.show()

        else:
            source_label = Gtk.Label("Original")
            self.table.attach(source_label, 1, 1+1, 0, 1+0)
            source_label.show()

            non_modified_target_label = Gtk.Label("Non Edited MT")
            self.table.attach(non_modified_target_label, 2, 2+1, 0, 1+0)
            non_modified_target_label.show()

            modified_target_label = Gtk.Label("Edited MT")
            self.table.attach(modified_target_label, 3, 3+1, 0, 1+0)
            modified_target_label.show()
main.py 文件源码 项目:MTTT 作者: roxana-lafuente 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _set_training(self):
        """@brief     Prepares GUI to run MT and LM training."""
        self.training = Gtk.Box()
        grid = Gtk.Grid()

        # Start training button.
        self.start_training_button = Gtk.Button("Start training")
        self.start_training_button.connect("clicked", self._train)
        grid.add(self.start_training_button)
        # Output frame.
        training_results_frame = Gtk.Frame(label="Results")
        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.set_hexpand(True)
        scrolledwindow.set_vexpand(True)
        resultsText = Gtk.TextView()
        resultsText.set_editable(False)
        resultsText.set_cursor_visible(False)
        resultsText.set_wrap_mode(True)
        self.trainingResultsTextBuffer = resultsText.get_buffer()
        scrolledwindow.add(resultsText)
        training_results_frame.add(scrolledwindow)
        grid.attach_next_to(training_results_frame,
                            self.start_training_button,
                            Gtk.PositionType.BOTTOM,
                            1,
                            1)

        self.training.add(grid)
        self.notebook.insert_page(self.training, Gtk.Label('Training'), 1)
__init__.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self,
                 parent=None,
                 title="",
                 primary=None,
                 secondary=None,
                 details=None,
                 buttons=Gtk.ButtonsType.OK,
                 type=Gtk.MessageType.INFO):
        Gtk.MessageDialog.__init__(self, parent, 0, type, buttons, primary)
        self.set_title(title)
        if secondary:
            self.format_secondary_markup(secondary)
        if details:
            textview = Gtk.TextView()
            textview.get_buffer().set_text(details)
            scroll = Gtk.ScrolledWindow()
            scroll.set_size_request(500, 300)
            scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
                Gtk.PolicyType.AUTOMATIC)
            scroll.add(textview)
            expand = Gtk.Expander().new(_("Details"))
            expand.add(scroll)
            expand.show_all()
            self.get_content_area().pack_start(expand, True, True, 0)
        if parent:
            self.set_modal(True)
            self.set_property("skip-taskbar-hint", True)
__init__.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self,
                 parent=None,
                 title="",
                 primary=None,
                 secondary=None,
                 details=None,
                 buttons=Gtk.ButtonsType.OK,
                 type=Gtk.MessageType.INFO):
        Gtk.MessageDialog.__init__(self, parent, 0, type, buttons, primary)
        self.set_title(title)
        if secondary:
            self.format_secondary_markup(secondary)
        if details:
            textview = Gtk.TextView()
            textview.get_buffer().set_text(details)
            scroll = Gtk.ScrolledWindow()
            scroll.set_size_request(500, 300)
            scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
                Gtk.PolicyType.AUTOMATIC)
            scroll.add(textview)
            expand = Gtk.Expander().new(_("Details"))
            expand.add(scroll)
            expand.show_all()
            self.get_content_area().pack_start(expand, True, True, 0)
        if parent:
            self.set_modal(True)
            self.set_property("skip-taskbar-hint", True)
engine_output.py 文件源码 项目:jcchess 作者: johncheetham 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self):
        glade_dir = gv.jcchess.get_glade_dir()
        self.glade_file = os.path.join(glade_dir, "engine_output.glade")
        Engine_Output.engine_output_ref = self

        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file)
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("engine_output_window")
        self.tv = [Gtk.TextView(), Gtk.TextView()]
        self.tv[0] = self.builder.get_object("engine_output_textview1")
        self.tv[1] = self.builder.get_object("engine_output_textview2")
        self.tv[0].set_editable(False)
        self.tv[1].set_editable(False)

        tabs = Pango.TabArray.new(4, True)
        tabs.set_tab(0, Pango.TabAlign.LEFT, 40)
        tabs.set_tab(1, Pango.TabAlign.LEFT, 160)
        tabs.set_tab(2, Pango.TabAlign.LEFT, 230)
        tabs.set_tab(3, Pango.TabAlign.LEFT, 280)

        self.tv[0].set_tabs(tabs)
        self.tv[1].set_tabs(tabs)

        self.tb = [Gtk.TextBuffer(), Gtk.TextBuffer()]
        self.tb[0] = self.tv[0].get_buffer()
        self.tb[1] = self.tv[1].get_buffer()
        # self.tb[0].set_text("")
        # self.tb[1].set_text("")

        self.nps_lbl = [Gtk.Label(), Gtk.Label()]
        self.nps_lbl[0] = self.builder.get_object("engine_output_nodes_lbl1")
        self.nps_lbl[1] = self.builder.get_object("engine_output_nodes_lbl2")

        self.engine_name_lbl = [Gtk.Label(), Gtk.Label()]
        self.engine_name_lbl[0] = self.builder.get_object(
            "engine_output_engine_name_lbl1")
        self.engine_name_lbl[1] = self.builder.get_object(
            "engine_output_engine_name_lbl2")

        self.ponder_move_lbl = [Gtk.Label(), Gtk.Label()]
        self.ponder_move_lbl[0] = self.builder.get_object(
            "engine_output_ponder_move_lbl1")
        self.ponder_move_lbl[1] = self.builder.get_object(
            "engine_output_ponder_move_lbl2")

        self.currmove_lbl = [Gtk.Label(), Gtk.Label()]
        self.currmove_lbl[0] = self.builder.get_object(
            "engine_output_currmove_lbl1")
        self.currmove_lbl[1] = self.builder.get_object(
            "engine_output_currmove_lbl2")

        # self.window.show_all()

    # user has closed the window
    # just hide it
functions.py 文件源码 项目:poseidon 作者: sidus-dev 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def pass_generator(self):

    if self.tabs[self.current_page][0]\
    .scrolled_window.get_name() != "webview": return True

    window = build_window(self, 0, 0)
    window.set_titlebar(build_headerbar(_("Password Generator"), None, 1))

    entry = make_box("{} (Def: 32) (Max: 99999)".format(_("Password Length")), 5, 1)
    button = Gtk.Button(label=_("Generate"))
    copy = Gtk.Button(label=_("Copy"))
    result = Gtk.TextView()
    result.set_top_margin(10)
    result.set_left_margin(10)
    result.set_wrap_mode(Gtk.WrapMode.WORD)
    scrolled_window = Gtk.ScrolledWindow()
    scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
    scrolled_window.set_size_request(400, 200)
    scrolled_window.add(result)

    bt_grid = Gtk.Grid()
    bt_grid.set_column_spacing(10)
    bt_grid.attach(button, 1, 0, 1, 1)
    bt_grid.attach(copy, 2, 0, 1, 1)
    bt_grid.set_column_homogeneous(True)

    grid = Gtk.Grid()
    grid.attach(entry, 0, 0, 1, 1)
    grid.attach(scrolled_window, 0, 1, 1, 1)
    grid.attach(bt_grid, 0, 2, 1, 1)

    entry.set_property("margin-bottom", 15)
    bt_grid.set_property("margin-top", 15)
    grid.set_property("margin", 15)

    window.add(grid)
    window.show_all()

    clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

    for i in entry:
        if type(i) == Gtk.Entry: entry = i

    button.connect("clicked", lambda x: pass_generate(entry.get_text(), 32, result))
    copy.connect("clicked", lambda x: clipboard.set_text(result.get_buffer().\
    get_text(result.get_buffer().get_start_iter(),result.get_buffer().get_end_iter(), False), -1))


问题


面经


文章

微信
公众号

扫码关注公众号