'PyGTK how to pass a Liststore row value to another class in another python file
In Glade, I created a Liststore
that shows me a list of people. When I click on a line, then the line number is inserted into the self.radek_k_editaci
variable in the list_list method. It's alright.
However, I can't figure out how to use this value in another python file with a different class. I just can't get the value of this variable in another class in a single python file.
from class_database import *
from gi.repository import Gtk
import gi
import os
gi.require_version("Gtk", "3.0")
from class_database import Database
class Handler:
def onDestroy(self, *args):
Gtk.main_quit()
def __init__(self):
pass
def list_seznam(self, listseznam):
(model, pathlist) = listseznam.get_selected_rows()
for path in pathlist:
tree_iter = model.get_iter(path)
#need value of below variable anywhere else
self.radek_k_editaci = model.get_value(tree_iter,0)
handler = Handler()
if __name__ == "__main__":
database = Database()
builder = Gtk.Builder()
builder.add_from_file("list.glade")
seznam = database.vypis_vseho()
model = builder.get_object("liststore")
builder.connect_signals(Handler())
model.clear()
for i in range(len(seznam)):
model.append(seznam[i])
window = builder.get_object("win_list")
window.show_all()
Gtk.main()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|