Refactor and documentation.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
This modules contains general utilities for the GTK application to use.
|
||||
"""
|
||||
|
||||
import os
|
||||
from zipfile import ZipFile
|
||||
|
||||
@@ -5,7 +9,11 @@ from zipfile import ZipFile
|
||||
class Util:
|
||||
@staticmethod
|
||||
def get_combo_value(combo, index: int):
|
||||
""" Retrieve the selected value of a combo box at the selected index in the model """
|
||||
""" Retrieve the selected value of a combo box at the selected index in the model
|
||||
:param combo: Any Gtk Widget that supports 'get_active_iter()'
|
||||
:param index: Index of the value in the widgets model to be retrieved
|
||||
:return: The value of the model at the selected index (Default -1)
|
||||
"""
|
||||
tree_iter = combo.get_active_iter()
|
||||
if tree_iter:
|
||||
return combo.get_model().get_value(tree_iter, index)
|
||||
@@ -13,8 +21,14 @@ class Util:
|
||||
return -1
|
||||
|
||||
@staticmethod
|
||||
def get_index_of_combo_model(combo, column: int, value: int):
|
||||
model = combo.get_model()
|
||||
def get_index_of_combo_model(widget, column: int, value: int):
|
||||
"""Get the index of a value within a Gtk widgets model based on column an value
|
||||
:param widget: Any Gtk widget that can be bound to a ListStore or TreeStore
|
||||
:param column: Column in the model where to look for the value
|
||||
:param value: Value to look for in the model
|
||||
:return: List of the indexes where the value occurs
|
||||
"""
|
||||
model = widget.get_model()
|
||||
return [model.index(entry) for entry in model if entry[column] == value]
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user