Gdk.cairo_set_source_pixbuf( cr, pixbuf, available_width / 2 - width * scale / 2, available_height / 2 - height * scale / 2, ) cr.paint() def on_ok_clicked(self, button: Gtk.Button) -> None: """React to the "OK" button being clicked. Args: button (Gtk.Button): The button that was clicked """ self.get_toplevel().switch_page("select_program", 90, 90) # TODO: Use actual values def on_save_pos_clicked(self, button: Gtk.Button) -> None: """React to the "Save position" button being clicked. Args: button (Gtk.Button): The button that was clicked """ self.ok_button.set_sensitive(True) GObject.type_ensure(SetupPage) # avg([float(s) for s in x.split("\n")])
def load_widgets(): GObject.type_ensure(PasswordGeneratorPopover) GObject.type_ensure(UnlockedHeaderBar) GObject.type_ensure(WelcomePage) GObject.type_ensure(ErrorRevealer) GObject.type_ensure(ExpirationDateRow) GObject.type_ensure(LockedHeaderBar) GObject.type_ensure(NotesDialog) GObject.type_ensure(PasswordLevelBar) GObject.type_ensure(PreferencesRow) GObject.type_ensure(ProgressIcon) GObject.type_ensure(SelectionModeHeaderbar)
import gi gi.require_version('GtkSource', '3.0') from gi.repository import Gtk, GObject, GtkSource, Gdk, GLib, Gio from draftsrc import file from draftsrc import db from draftsrc.markup import MarkdownSymbols from draftsrc.widgets.editor.statusbar import DraftStatusbar from draftsrc.widgets.editor.thesaurusbox import DraftThesaurusBox from draftsrc.widgets.editor.searchbox import DraftSearchBox from draftsrc.widgets.editor.sourceview import DraftSourceView # Ensure that GtkBuilder actually recognises SourceView in UI file GObject.type_ensure(GObject.GType(GtkSource.View)) class DraftEditor(Gtk.Overlay): __gtype_name__ = 'DraftEditor' __gsignals__ = { 'text-viewed': (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_PYOBJECT, )), 'view-transposed': (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_STRING, GObject.TYPE_INT, GObject.TYPE_INT)), 'escape-edit': (GObject.SignalFlags.RUN_FIRST, None, ()) } class _ViewData(object):
Args: button (Gtk.Button): The clicked button """ assert self.patient is not None dialog = Gtk.MessageDialog( self.get_toplevel(), Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, ("Nein", Gtk.ResponseType.NO, "Ja", Gtk.ResponseType.YES), (f"Patient {self.patient.first_name} {self.patient.last_name}" " unwiderruflich löschen?"), ) dialog.set_decorated(False) response: int = dialog.run() dialog.destroy() if response == Gtk.ResponseType.YES: self.patient.delete() self.get_toplevel().go_back() while self.get_toplevel().active_patient is self.patient: self.get_toplevel().go_back() elif response == Gtk.ResponseType.NO: pass # Make EditPatientPage accessible via .ui files GObject.type_ensure(EditPatientPage)
# %%WIDGET_NAME%%: Union[Gtk.Widget, Gtk.Template.Child] = Gtk.Template.Child() def __init__(self, **kwargs): """Create a new TreatmentPage. Args: **kwargs: Arguments passed on to Gtk.Box """ super().__init__(**kwargs) def prepare(self) -> None: """Prepare the page to be shown.""" def do_parent_set(self, old_parent: Optional[Gtk.Widget]) -> None: """React to the parent being set. When this method is called, it is assumed that all sub-widgets are ready to have signals connected. Args: old_parent (Optional[Gtk.Widget]): The old parent """ if self.get_parent() is None: return # Connect events # Make TreatmentPage accessible via .ui files GObject.type_ensure(TreatmentPage)
old_parent (Optional[Gtk.Widget]): The old parent """ if self.get_parent() is None: return self.header_box.pack_start(UserHeader(), fill=True, expand=True, padding=0) self.header_box.show_all() self.add_button.connect("clicked", self.on_add_clicked) def on_add_clicked(self, button: Gtk.Button) -> None: """React to the "Add user" button being clicked. Args: button (Gtk.Button): The clicked button """ self.get_toplevel().switch_page( "register", new_user=True, # Hardcoded access level because that hopefully # isn't changing anytime soon access_level="helper", ) # Make UsersPage accessible via .ui files GObject.type_ensure(UsersPage)
Args: button (Gtk.Button): Description Deleted Parameters: widget (Gtk.Widget): The focused entry. event (Gdk.EventFocus): The focus event. """ try: if auth_util.authenticate(self.username_entry.get_text(), self.password_entry.get_text()): self.get_toplevel().active_user = ( self.username_entry.get_text()) self.get_toplevel().active_user_password = ( self.password_entry.get_text()) self.get_toplevel().switch_page("select_patient") self.get_toplevel().clear_history() else: self.password_entry.get_style_context().add_class("error") self.password_entry.grab_focus_without_selecting() except ValueError as e: print(e) self.username_entry.get_style_context().add_class("error") self.username_entry.grab_focus_without_selecting() # Make LoginPage accessible via .ui files GObject.type_ensure(LoginPage)
""" self.save_button.set_sensitive(True) def on_save_clicked(self, button: Gtk.Button) -> None: """React to the save button being clicked. Args: button (Gtk.Button): The button that was clicked """ window: Gtk.Window = self.get_toplevel() if window.treatment_timestamp is None: window.treatment_timestamp = window.active_patient.add_pain_entry( window.active_user, self.pain_scale.get_value(), self.pain_location_combobox_text.get_active_id(), ) else: window.treatment_timestamp = window.active_patient.modify_pain_entry( window.treatment_timestamp, window.active_user, self.pain_scale.get_value(), self.pain_location_combobox_text.get_active_id(), ) window.switch_page("setup") # Make PainEvaluationPage accessible via .ui files GObject.type_ensure(PainEvaluationPage)
self.program.modify( **{ self.entries[entry]["column"]: float(entry.get_text().replace( ",", ".")) for entry in self.entries if not self.entries[entry]["calculated_column"] }) def on_save_new_clicked(self, button: Gtk.Button) -> None: """React to the user clicking on the "Save as new" button. Args: button (Gtk.Button): The clicked button """ self.program = program_util.Program.add({ self.entries[entry]["column"]: program_util.PROGRAM_COLUMNS[self.entries[entry]["column"]][0]( float(entry.get_text().replace(",", "."))) for entry in self.entries if not self.entries[entry]["calculated_column"] }) self.title = f"Programm {self.program.id}" self.get_toplevel().update_title() self.update_save_sensitivities() # Make EditProgramPage accessible via .ui files GObject.type_ensure(EditProgramPage)
self.username, self.password_entry.get_text(), self.get_toplevel().active_user, self.get_toplevel().active_user_password, ) else: auth_util.modify_password( self.get_toplevel().active_user, self.get_toplevel().active_user_password, self.password_entry.get_text(), ) self.get_toplevel().active_user_password = ( self.password_entry.get_text()) else: raise ValueError( "A user must be logged in to change a password") if self.next_page is None: self.get_toplevel().go_back() else: self.get_toplevel().switch_page(self.next_page, *self.next_page_args, **self.next_page_kwargs) except ValueError as v_err: self.get_toplevel().show_error(" ".join(v_err.args)) # Make RegisterPage accessible via .ui files GObject.type_ensure(RegisterPage)
entered the query into """ self.update_patients() def sort_key(self, patient_row: Tuple[Any, ...]) -> Any: """Return a sort key for a patient row. Args: patient_row (Tuple[Any, ...]): The patient row Returns: Any: An object by which patient_row can be sorted """ return patient_row[self.sort_column] def set_sort(self, column_index: int, reverse: bool) -> None: """Set the sort parameters and sort the patients if necessary. Args: column_index (int): The index of the column by which to sort reverse (bool): Whether to reverse the sorted rows """ if reverse != self.sort_reverse or column_index != self.sort_column: self.sort_column = column_index self.sort_reverse = reverse self.update_patients() # Make SelectPatientPage accessible via .ui files GObject.type_ensure(SelectPatientPage)
self.program_list_box.connect("row-selected", self.on_program_selected) self.add_button.connect("clicked", self.on_add_clicked) def on_program_selected(self, list_box: Gtk.ListBox, row: Gtk.ListBoxRow): """React to the user selecting a program. This will switch to the page 'pain_evaluation'. Args: list_box (Gtk.ListBox): The Gtk.ListBox that is the row's parent row (Gtk.ListBoxRow): The Gtk.ListBoxRow that was selected """ if row is not None: self.get_toplevel().active_program = row.get_child().program self.get_toplevel().switch_page("treatment") list_box.unselect_all() def on_add_clicked(self, button: Gtk.Button) -> None: """React to the "add program" button being clicked. Args: button (Gtk.Button): The clicked button """ self.get_toplevel().switch_page("edit_program") # Make SelectProgramPage accessible via .ui files GObject.type_ensure(SelectProgramPage)
self.fontsListBox.show() @Gtk.Template(resource_path='/org/gustavoperedo/FontDownloader/fontpreview.ui') class FontPreviewPane(Gtk.Frame): __gtype_name__ = 'FontPreviewPane' fontPreviewWebview = Gtk.Template.Child() fontPreviewText = Gtk.Template.Child() def __init__(self, **kwargs): self.html = '' super().__init__(**kwargs) GObject.type_ensure(Handy.TitleBar) @Gtk.Template(resource_path='/org/gustavoperedo/FontDownloader/window.ui') class FontdownloaderWindow(Gtk.ApplicationWindow): __gtype_name__ = 'FontdownloaderWindow' list_pane_stack = Gtk.Template.Child() fontpreview_pane = Gtk.Template.Child() back_button = Gtk.Template.Child() main_download_button = Gtk.Template.Child() compact_download_button = Gtk.Template.Child() main_install_button = Gtk.Template.Child() compact_install_button = Gtk.Template.Child() search_button = Gtk.Template.Child() all_check = Gtk.Template.Child()