Быстрое переключение документации

Кто-нибудь знает, где я могу найти документацию на Switch Widget на glade ??

Я попытался найти на веб-сайте GTK, но у него нет записи для него.

EDIT

Спасибо Тимо за то, что указали мне в правильном направлении.

В основном моя проблема заключалась в том, что функция connect defualts подталкивает объект Window, объект виджетов и активное состояние к любой функции, которую вы выполняете при обратном вызове.

] Это прежде:

self.daymon.connect("notify::active", self.toggle_day("mon"))

Это прежде:

self.daymon.connect('notify::active', self.toggle_day, "mon")

Последний работает как прелесть при запуске следующей функции:

def toggle_day(self, widget, active, day):  
    if widget.get_active():  
        state = True  
    else:  
        state = False  

Это прежде:

# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# This file is in the public domain
### END LICENSE

import gettext
from gettext import gettext as _
gettext.textdomain('snooze')

from gi.repository import Gtk # pylint: disable=E0611
import logging
logger = logging.getLogger('snooze')

import ConfigParser, os # We need to be able to store and recal settings

from snooze_lib import Window
from snooze.AboutSnoozeDialog import AboutSnoozeDialog
from snooze.PreferencesSnoozeDialog import PreferencesSnoozeDialog

#first try to read the config.cfg file
config = ConfigParser.RawConfigParser()
configFile = 'data/config.cfg'
monState = False
tueState = False
wedState = False
thurState = False
friState = False
satState = False
sunState = False

# Creating the Config file
def createConfigFile(fileName):
    print "CREATING CONFIG"
    config.add_section('Preferences')
    config.set('Preferences', 'mon', False)
    config.set('Preferences', 'tues', False)
    config.set('Preferences', 'wed', False)
    config.set('Preferences', 'thur', False)
    config.set('Preferences', 'fri', False)
    config.set('Preferences', 'sat', False)
    config.set('Preferences', 'sun', False)
    rewriteConfigFile(filename)

# Writing our configuration file to the failename as specifeid
def rewriteConfigFile(filename):    
    with open(filename, 'wb') as configfile:
        config.write(configfile)

# Reading the config file 
def readConfigFile(fileName):
    print "READING CONFIG"
    global monState, tueState, wedState, thurState, friState, satState, sunState
    monState = config.getboolean('Preferences', 'mon')
    tueState = config.getboolean('Preferences', 'tues')
    wedState = config.getboolean('Preferences', 'wed')
    thurState = config.getboolean('Preferences', 'thur')
    friState = config.getboolean('Preferences', 'fri')
    satState = config.getboolean('Preferences', 'sat')
    sunState = config.getboolean('Preferences', 'sun')

# If the config does not exist, create it then read it. Otherwise read it
if not config.read(configFile):    
    createConfigFile(configFile)
    readConfigFile(configFile)    
else:
    readConfigFile(configFile)

# See snooze_lib.Window.py for more details about how this class works
class SnoozeWindow(Window):
    __gtype_name__ = "SnoozeWindow"

    def finish_initializing(self, builder): # pylint: disable=E1002
        """Set up the main window"""
        super(SnoozeWindow, self).finish_initializing(builder)

        self.AboutDialog = AboutSnoozeDialog
        self.PreferencesDialog = PreferencesSnoozeDialog

        # Code for other initialization actions should be added here.
        self.daymon = self.builder.get_object("daymon")
        self.daytues = self.builder.get_object("daytues")
        self.daywed = self.builder.get_object("daywed")
        self.daythur = self.builder.get_object("daythur")
        self.dayfri = self.builder.get_object("dayfri")
        self.daysat = self.builder.get_object("daysat")
        self.daysun = self.builder.get_object("daysun")

        # Set the values based on the config file        
        if monState == True:
            self.daymon.activate()

        if tueState == True:
            self.daytues.activate()

        if wedState == True:
            self.daywed.activate()

        if thurState == True:
            self.daythur.activate()

        if friState == True:
            self.dayfri.activate()

        if satState == True:
            self.daysat.activate()

        if sunState == True:
           self.daysun.activate()

        self.daymon.connect('notify::active', self.toggle_day, "mon")
        self.daytues.connect('notify::active', self.toggle_day, "tues")
        self.daywed.connect('notify::active', self.toggle_day, "wed")
        self.daythur.connect('notify::active', self.toggle_day, "thur")
        self.dayfri.connect('notify::active', self.toggle_day, "fri")
        self.daysat.connect('notify::active', self.toggle_day, "sat")
        self.daysun.connect('notify::active', self.toggle_day, "sun")

    # Toggle the setting and store the information in the config file
    def toggle_day(self, widget, active, day):
        if widget.get_active():
            state = True
        else:
            state = False

        # Set the config option and update the config file
        global configFile
        config.set('Preferences', day, state)
        rewriteConfigFile(configFile)

1
задан 13 November 2012 в 01:03

0 ответов

Другие вопросы по тегам:

Похожие вопросы: