Ok danke.
Habe es entsprechend angepasst.
Leider ist mir immer noch nicht ganz bewusst wie ich am besten 'functools.partial()' einsetzen kann:
Code: Alles auswählen
#
# Copyright (c) 2011-2018 Kiefer Networks (https://kiefer-networks.de)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#
# Authored by: Malte Kiefer <malte.kiefer@kiefer-networks.de>
#
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk, Gio
from Services import dbFiles
class Invoicy(Gtk.Window):
    COMPANY = ""
    CONTACT = ""
    STREET = ""
    ZIP = ""
    PLACE = ""
    COUNTRY = ""
    CURRENCY = ""
    CURRENCYPOSITION = 0
    def __init__(self):
        Gtk.Window.__init__(self, title="Invoicy")
        self.set_border_width = 10
        self.set_default_size(800, 600)
        header_bar = Gtk.HeaderBar()
        header_bar.set_show_close_button(True)
        header_bar.props.title = "Invoicy"
        self.set_titlebar(header_bar)
        newbutton = Gtk.Button()
        image = Gtk.Image.new_from_gicon(Gio.ThemedIcon(name="document-new"), Gtk.IconSize.LARGE_TOOLBAR)
        newbutton.add(image)
        header_bar.pack_start(newbutton)
        menubutton = Gtk.Button()
        image = Gtk.Image.new_from_gicon(Gio.ThemedIcon(name="open-menu"), Gtk.IconSize.LARGE_TOOLBAR)
        menubutton.add(image)
        menubutton.connect("clicked", self.on_menubutton_click)
        header_bar.pack_end(menubutton)
        treestore = Gtk.TreeStore(str, str)
        a = dbFiles.dbFiles()
        invoices = a.read_all_invoices()
        for invoice in invoices:
            treestore.append(None, [invoice['InvoiceNumber'], invoice['Date']])
        treeview = Gtk.TreeView(treestore)
        renderer_number = Gtk.CellRendererText()
        renderer_date = Gtk.CellRendererText()
        col_number = Gtk.TreeViewColumn('Number', renderer_number, text=0)
        col_date = Gtk.TreeViewColumn('Date', renderer_date, text=0)
        treeview.append_column(col_number)
        treeview.append_column(col_date)
        self.add(treeview)
    def on_menubutton_click(self, widget):
        dialog = self.settingsdialog()
        #response = dialog.run()
        #if response == Gtk.ResponseType.OK:
        #    print("The OK button was clicked")
        #elif response == Gtk.ResponseType.CANCEL:
        #    print("The Cancel button was clicked")
        dialog.destroy()
    def settingsdialog (self):
        dialog = Gtk.Dialog()
        dialog.set_default_size(300, 300)
        dialog.set_transient_for(self)
        dialog.set_modal(True)
        dialog.add_button(button_text="Save", response_id=Gtk.ResponseType.OK)
        dialog.connect("response", self.set_company_data)
        grid = Gtk.Grid(column_spacing=10, row_spacing=10)
        grid.props.margin_left = 20
        grid.props.margin_right = 20
        grid.props.margin_top = 20
        grid.props.margin_bottom = 20
        self.get_company_data(self)
        header = Gtk.Label()
        header.set_markup("<big><b>Settings</b></big>")
        header_company = Gtk.Label()
        header_company.set_markup("<b>Company</b>")
        finance_company = Gtk.Label()
        finance_company.set_markup("<b>Finance</b>")
        companyname_label = Gtk.Label("Company")
        companyname_entry = Gtk.Entry()
        companyname_entry.set_text(Invoicy.COMPANY)
        companycontact_label = Gtk.Label("Name")
        companycontact_entry = Gtk.Entry()
        companycontact_entry.set_text(Invoicy.CONTACT)
        companystreet_label = Gtk.Label("Street")
        companystreet_entry = Gtk.Entry()
        companystreet_entry.set_text(Invoicy.STREET)
        companyzip_label = Gtk.Label("ZIP")
        companyzip_entry = Gtk.Entry()
        companyzip_entry.set_text(Invoicy.ZIP)
        companyplace_label = Gtk.Label("Place")
        companyplace_entry = Gtk.Entry()
        companyplace_entry.set_text(Invoicy.PLACE)
        companycountry_label = Gtk.Label("Country")
        companycountry_entry = Gtk.Entry()
        companycountry_entry.set_text(Invoicy.COUNTRY)
        financecurrency_label = Gtk.Label("Currency Symbole")
        financecurrency_entry = Gtk.Entry()
        financecurrency_entry.set_text(Invoicy.CURRENCY)
        financecurrencyposition_label = Gtk.Label("Position Currency Symbole")
        financecurrencyposition_combo = Gtk.ComboBoxText()
        financecurrencyposition_combo.insert(0, "0", "Before")
        financecurrencyposition_combo.insert(1, "1", "After")
        financecurrencyposition_combo.set_active(Invoicy.CURRENCYPOSITION)
        grid.add(header)
        grid.attach(header_company, 0, 1, 2, 1)
        grid.attach(companyname_label, 0, 2, 1, 1)
        grid.attach(companyname_entry, 1, 2, 1, 1)
        grid.attach(companycontact_label, 0, 3, 1, 1)
        grid.attach(companycontact_entry, 1, 3, 1, 1)
        grid.attach(companystreet_label, 0, 4, 1, 1)
        grid.attach(companystreet_entry, 1, 4, 1, 1)
        grid.attach(companyzip_label, 0, 5, 1, 1)
        grid.attach(companyzip_entry, 1, 5, 1, 1)
        grid.attach(companyplace_label, 0, 6, 1, 1)
        grid.attach(companyplace_entry, 1, 6, 1, 1)
        grid.attach(companycountry_label, 0, 7, 1, 1)
        grid.attach(companycountry_entry, 1, 7, 1, 1)
        grid.attach(finance_company, 0, 8, 2, 1)
        grid.attach(financecurrency_label, 0, 9, 1, 1)
        grid.attach(financecurrency_entry, 1, 9, 1, 1)
        grid.attach(financecurrencyposition_label, 0, 10, 1, 1)
        grid.attach(financecurrencyposition_combo, 1, 10, 1, 1)
        box = dialog.get_content_area()
        box.add(grid)
        dialog.show_all()
    @staticmethod
    def get_company_data(self):
        company = dbFiles.dbFiles()
        company_data = company.read_company()
        for data in company_data:
            if 'Name' in data:
                Invoicy.COMPANY = data["Name"]
            if 'Contact' in data:
                Invoicy.CONTACT = data["Contact"]
            if 'Street' in data:
                Invoicy.STREET = data["Street"]
            if 'ZIP' in data:
                Invoicy.ZIP = data["ZIP"]
            if 'Place' in data:
                Invoicy.PLACE = data["Place"]
            if 'Country' in data:
                Invoicy.COUNTRY = data["Country"]
            if 'Currency' in data:
                Invoicy.CURRENCY = data["Currency"]
            if 'CurrencyPositon' in data:
                Invoicy.CURRENCYPOSITION = data["CurrencyPositon"]
    def set_company_data(self,  widget, event):
        print(self.companycountry_entry.get_text())
        widget.destroy()
win = Invoicy()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()