本文整理汇总了Python中kivy.config.ConfigParser.get方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.get方法的具体用法?Python ConfigParser.get怎么用?Python ConfigParser.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddCardMenuScreen
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class AddCardMenuScreen(Screen):
question = ""
answer = ""
def __init__(self):
Screen.__init__(self)
self.name = "add"
self.config = ConfigParser()
self.config.add_section("add")
self.config.set("add", "question", "Question")
self.config.set("add", "answer", "Answer")
self.config.set("add", "make", "action")
self.config.add_callback(self.update_qa, section="add", key="question")
self.config.add_callback(self.update_qa, section="add", key="answer")
self.menu = SettingsWithNoMenu()
self.menu.register_type("action", FlashcardAppManager.SettingDoAction)
self.menu.add_json_panel("Add a card", self.config, os.path.join(os.path.dirname(__file__), 'add_menu.json'))
self.add_widget(self.menu)
def update_qa(self, *args):
FlashcardAppManager.AddCardMenuScreen.question = self.config.get('add', 'question')
FlashcardAppManager.AddCardMenuScreen.answer = self.config.get('add', 'answer')
示例2: EditCardMenuScreen
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class EditCardMenuScreen(Screen):
question = ""
answer = ""
nquestion = ""
nanswer = ""
EditCardMenuConfig = None
def update_qa(self, *args):
FlashcardAppManager.EditCardMenuScreen.nquestion = self.config.get('edit', 'nquestion')
FlashcardAppManager.EditCardMenuScreen.nanswer = self.config.get("edit", "nanswer")
def __init__(self):
Screen.__init__(self)
self.name = "edit"
self.config = ConfigParser()
self.config.add_section("edit")
self.config.set("edit", "question", "Question")
self.config.set("edit", "answer", "Answer")
self.config.set("edit", "nquestion", "Question")
self.config.set("edit", "nanswer", "Answer")
self.config.set("edit", "edit", "action")
FlashcardAppManager.EditCardMenuScreen.question = self.config.get('edit', 'question')
FlashcardAppManager.EditCardMenuScreen.answer = self.config.get('edit', 'answer')
FlashcardAppManager.EditCardMenuScreen.nquestion = self.config.get('edit', 'nquestion')
FlashcardAppManager.EditCardMenuScreen.nanswer = self.config.get('edit', 'nanswer')
self.config.add_callback(self.update_qa, section="edit", key="nquestion")
self.config.add_callback(self.update_qa, section="edit", key="nanswer")
self.menu = SettingsWithNoMenu()
self.menu.register_type("action", FlashcardAppManager.SettingDoAction)
self.menu.add_json_panel("Add a card", self.config, os.path.join(os.path.dirname(__file__), 'edit_menu.json'))
FlashcardAppManager.EditCardMenuScreen.EditCardMenuConfig = self.config
self.add_widget(self.menu)
def on_pre_enter(self, *args):
FlashcardAppManager.EditCardMenuScreen.question = FlashcardAppManager.deck_widget.deck.get_selected().get_question()
FlashcardAppManager.EditCardMenuScreen.answer = FlashcardAppManager.deck_widget.deck.get_selected().get_answer()
self.config.set("edit", "question", FlashcardAppManager.EditCardMenuScreen.question)
self.config.set("edit", "answer", FlashcardAppManager.EditCardMenuScreen.answer)
示例3: on_start
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
def on_start(self):
"""
Método chamado para inicializar o menu inicial
:return: nada
"""
Window.size = (300, 100)
config = ConfigParser()
# Carrega últimas configurações utilizadas (ou padrões se arquivo não é encontrado)
config.read('settings.ini')
self.username = config.get('section0', 'key00')
self.color = SettingsApp.get_color(config.get('section0', 'key01'))
if config.get('section1', 'key10') == "Single":
self.is_multiplayer = False
else:
self.is_multiplayer = True
self.match = config.get('section1', 'key11')
self.rows = config.getint('section2', 'key20')
self.columns = config.getint('section2', 'key21')
self.bombs = config.getint('section3', 'key30')
示例4: MenuScreen
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class MenuScreen(Screen):
def __init__(self):
Screen.__init__(self)
self.name = 'menu'
self.config = ConfigParser()
self.config.add_section("deck")
self.config.add_section("card")
self.config.adddefaultsection("menu")
self.config.set("deck", "start_studying", 1)
self.config.set("deck", "change_deck_mode", "Normal")
self.config.set("deck", "show_list", True)
self.config.set("deck", "undo", True)
self.config.set("deck", "redo", True)
self.config.set("card", "add", "")
self.config.set("card", "edit", True)
self.config.set("card", "remove", True)
self.config.add_callback(self.check_deck_locks, "deck", "redo")
self.config.add_callback(self.check_deck_locks, "deck", "undo")
self.config.add_callback(self.check_card_locks, "card", "edit")
self.config.add_callback(self.check_card_locks, "card", "add")
self.menu = SettingsWithNoMenu()
self.menu.register_type("screen", FlashcardAppManager.SettingNewScreen)
self.menu.register_type("action", FlashcardAppManager.SettingDoAction)
self.menu.add_json_panel("Flashcards", self.config, os.path.join(os.path.dirname(__file__), 'menu.json'))
self.add_widget(self.menu)
def check_deck_locks(self, section, key, value):
print(self.config.get(section, key))
def check_card_locks(self, section, key, value):
print()
示例5: update_program
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
def update_program(self):
"""Проверяет наличие обновлений на сервере github,com.
Проверяестя версия программы, версии плагинов, наличие измененных
программых файлов."""
if platform != "android":
print("Проверка обновлений:")
print("------------------------------------")
temp_path = "{}/Data/temp".format(core.prog_path)
if not os.path.exists(temp_path):
os.mkdir(temp_path)
update_file = urllib.urlopen(
"https://github.com/HeaTTheatR/HeaTDV4A/raw/master/"
"Data/uploadinfo.ini").read()
open("{}/uploadinfo.ini".format(temp_path), "w").write(
update_file)
config_update = ConfigParser()
config_update.read("{}/uploadinfo.ini".format(temp_path))
info_list_update = []
new_version_program = \
config_update.getfloat("info_update", "new_version_program")
updated_files_program = \
eval(config_update.get("info_update", "updated_files_program"))
dict_official_plugins_program = \
config_update.items("plugin_update")
official_plugins_program = dict(dict_official_plugins_program)
install_user_plugins = self.started_plugins
current_version_program = __version__
if platform != "android":
print("Проверка версии программы ...")
print("Проверка актуальности плагинов ...")
for plugin in install_user_plugins.keys():
try:
info_official_plugin = eval(official_plugins_program[plugin])
if info_official_plugin[plugin]['plugin-version'] > \
install_user_plugins[plugin]['plugin-version']:
info_list_update.append(info_official_plugin)
if platform != "android":
print("Плагин '{}' обновился до версии '{}'!".format(
plugin, info_official_plugin[plugin][
'plugin-version']))
except KeyError:
continue
if platform != "android":
print("Проверка обновлений завершена ...")
print("------------------------------------")
print()
if len(info_list_update) or new_version_program > \
current_version_program:
self.update = True
if platform != "android":
print("Доступны обновления!")
print("------------------------------------")
print()
else:
if platform != "android":
print("Обновлений нет!")
print("------------------------------------")
print()
示例6: Program
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class Program(App, prog_class.ShowPlugin, prog_class.ShowThemesForum,
prog_class.ShowSectionsForum, prog_class.ShowSendMailForm,
prog_class.ShowTopicsForum, prog_class.ShowListMail,
prog_class.ShowFileDetails, prog_class.ShowUploadForm,
prog_class.ShowFiles, prog_class.ShowUserProfile,
ConnectionToServer):
"""Функционал программы."""
# Языковая локализация - переменные с префиксом core.string_lang_.
# Используются в классах библиотеки programclass. В текущем классе -
# без ключевого слова self, так как были импортированы из programdata
exec(open("{}/Data/Language/{}.txt".format(
core.prog_path, language)).read().replace(
"#key_text_color", core.theme_key_text_color.encode("u8")).replace(
"#text_color", core.theme_text_color.encode("u8")).replace(
"#link_color", core.theme_link_color.encode("u8")))
# TODO: Константа CONST_SCREEN используется модулем kdialog для
# вычесления ширины диалогового окна (Window.size[0] / CONST_SCREEN).
# size_hint_x для этих целей неуместен. Например, при размере экрана
# 600x300 и параметре size_hint_x=.5 окно будет слишком
# узким и наоборот - 300x600 и тот же параметр size_hint_x - покажут окно
# занимаемое бОльшую плоскость экрана.
WIDTH, HEIGHT = Window.size
if WIDTH <= HEIGHT:
CONST_SCREEN = 1.2
else:
CONST_SCREEN = 2
window_text_size = 15
update = None # нет обновлений
messages_unread = None # количество новых сообщений
open_dialog = False # если True - открыто диалоговое окно
number_user = None # номер участника на сайте
cookie = None
site = "http://m.dimonvideo.ru"
previous_screen = None
def __init__(self, **kvargs):
super(Program, self).__init__(**kvargs)
Window.bind(on_keyboard=self.events_program)
# Для области видимомти в programclass.
self.FadeTransition = FadeTransition
self.Screen = Screen
self.Clock = Clock
# ----------------------------------
self.parsing_xml = parsing_xml
self.get_page = get_page
self.set_cookie = set_cookie
self.Manifest = Manifest
self.core = core
# ----------------------------------
self.sendmail = sendmail
self.setattachtoforum = setattachtoforum
# ----------------------------------
self.KDialog = KDialog
self.FileChooser = FileChooser
self.SelectColor = SelectColor
self.CustomSpinner = CustomSpinner
self.PageSendMail = PageSendMail
self.ScrollButton = ScrollButton
self.ThemesForum = ThemesForum
self.AboutDialog = AboutDialog
self.UploadFiles = UploadFiles
self.MessageViewer = MessageViewer
self.MailList = MailList
self.BugReporter = BugReporter
self.ImageViewer = ImageViewer
self.customspinner = customspinner
self._urllib = _urllib
self.traceback = traceback
# ----------------------------------
self.clipboard = clipboard
# ----------------------------------
self.theme_decorator_window = core.theme_decorator_window
def get_application_config(self):
return super(Program, self).get_application_config(
"{}/program.ini".format(core.prog_path))
def build_config(self, config):
config.adddefaultsection("General")
config.setdefault("General", "showonstartpage", u"Новости сайта")
config.setdefault("General", "language", u"Русский")
config.setdefault("General", "showwarning", "1")
config.setdefault("General", "resmessages", "1")
config.setdefault("General", "authorization", "0")
config.setdefault("General", "progresstextsize", "15")
config.setdefault("General", "downloadkey", "0")
config.setdefault("General", "downloadfolder",
{0: 'Downloads', 1: ''})
config.setdefault("General", "user_reg",
{"login": "login", "password": "password"})
config.adddefaultsection("Network")
config.setdefault("Network", "authoconnect", "0")
config.setdefault("Network", "checkattachtoforum", "1")
config.setdefault("Network", "loadscr", "0")
config.setdefault("Network", "authoupdate", "1")
#.........这里部分代码省略.........
示例7: Exception
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
raise Exception(traceback.format_exc())
__version__ = "0.01"
if callable(platform):
platform = platform()
if not os.path.exists("{}/program.ini".format(core.prog_path)) or open(
"{}/program.ini".format(core.prog_path)).read() == "":
language = "russian"
else:
config = ConfigParser()
config.read("{}/program.ini".format(core.prog_path))
language = core.select_locale[config.get("General", "language")]
del config
def p(*args):
pass
class Program(App, prog_class.ShowPlugin, prog_class.ShowThemesForum,
prog_class.ShowSectionsForum, prog_class.ShowSendMailForm,
prog_class.ShowTopicsForum, prog_class.ShowListMail,
prog_class.ShowFileDetails, prog_class.ShowUploadForm,
prog_class.ShowFiles, prog_class.ShowUserProfile,
ConnectionToServer):
"""Функционал программы."""
示例8: UserPrefs
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class UserPrefs(EventDispatcher):
'''
A class to manage user preferences for the RaceCapture app
'''
DEFAULT_DASHBOARD_SCREENS = ['5x_gauge_view', 'laptime_view', 'tach_view', 'rawchannel_view']
DEFAULT_PREFS_DICT = {'range_alerts': {},
'gauge_settings':{},
'screens':DEFAULT_DASHBOARD_SCREENS,
'alerts': {}}
DEFAULT_ANALYSIS_CHANNELS = ['Speed']
prefs_file_name = 'prefs.json'
def __init__(self, data_dir, user_files_dir, save_timeout=0.2, **kwargs):
self._prefs_dict = UserPrefs.DEFAULT_PREFS_DICT
self.config = ConfigParser()
self.data_dir = data_dir
self.user_files_dir = user_files_dir
self.prefs_file = path.join(self.data_dir, self.prefs_file_name)
self.register_event_type("on_pref_change")
self.load()
def on_pref_change(self, section, option, value):
pass
def set_range_alert(self, key, range_alert):
'''
Sets a range alert with the specified key
:param key the key for the range alert
:type string
:param range_alert the range alert
:type object
'''
self._prefs_dict["range_alerts"][key] = range_alert
self.save()
def get_range_alert(self, key, default=None):
'''
Retrives a range alert for the specified key
:param key the key for the range alert
:type key string
:param default the default value, optional
:type default user specified
:return the range alert, or the default value
'''
return self._prefs_dict["range_alerts"].get(key, default)
def get_alertrules(self, channel):
'''
Retrieve the alert_rules for the specified channel. If the
alertrules do not exist for the specified channel, return an empty
default AlertRuleCollection
:return AlertRuleCollection
'''
alertrules = self._prefs_dict['alerts'].get(channel)
if alertrules is None:
alertrules = AlertRuleCollection(channel, [])
self._prefs_dict['alerts'][channel] = alertrules
return alertrules
def set_alertrules(self, channel, alertrules):
self._prefs_dict['alerts'][channel] = alertrules
self.save()
def set_gauge_config(self, gauge_id, config_value):
'''
Stores a gauge configuration for the specified gauge_id
:param gauge_id the key for the gauge
:type gauge_id string
:param config_value the configuration value to set
:type config_value string
'''
self._prefs_dict["gauge_settings"][gauge_id] = config_value
self.save()
def get_gauge_config(self, gauge_id):
'''
Get the gauge configuration for the specified gauge_id
:param gauge_id the key for the gauge
:type string
:return the gauge configuration
'''
return self._prefs_dict["gauge_settings"].get(gauge_id, False)
def get_dashboard_screens(self):
return copy(self._prefs_dict['screens'])
def set_dashboard_screens(self, screens):
self._prefs_dict['screens'] = copy(screens)
self.save()
# Regular preferences below here
def get_last_selected_track_id(self):
return self.get_pref('track_detection', 'last_selected_track_id')
def get_last_selected_track_timestamp(self):
#.........这里部分代码省略.........
示例9: UserPrefs
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class UserPrefs(EventDispatcher):
'''
A class to manage user preferences for the RaceCapture app
'''
_schedule_save = None
_prefs_dict = {'range_alerts': {}, 'gauge_settings':{}}
store = None
prefs_file_name = 'prefs.json'
prefs_file = None
config = None
data_dir = '.'
user_files_dir = '.'
def __init__(self, data_dir, user_files_dir, save_timeout=2, **kwargs):
self.data_dir = data_dir
self.user_files_dir = user_files_dir
self.prefs_file = path.join(self.data_dir, self.prefs_file_name)
self.load()
self._schedule_save = Clock.create_trigger(self.save, save_timeout)
def set_range_alert(self, key, range_alert):
'''
Sets a range alert with the specified key
:param key the key for the range alert
:type string
:param range_alert the range alert
:type object
'''
self._prefs_dict["range_alerts"][key] = range_alert
self._schedule_save()
def get_range_alert(self, key, default=None):
'''
Retrives a range alert for the specified key
:param key the key for the range alert
:type key string
:param default the default value, optional
:type default user specified
:return the range alert, or the default value
'''
return self._prefs_dict["range_alerts"].get(key, default)
def set_gauge_config(self, gauge_id, channel):
'''
Stores a gauge configuration for the specified gauge_id
:param gauge_id the key for the gauge
:type gauge_id string
:param channel the configuration for the channel
:type channel object
'''
self._prefs_dict["gauge_settings"][gauge_id] = channel
self._schedule_save()
def get_gauge_config(self, gauge_id):
'''
Get the gauge configuration for the specified gauge_id
:param gauge_id the key for the gauge
:type string
:return the gauge configuration
'''
return self._prefs_dict["gauge_settings"].get(gauge_id, False)
def get_last_selected_track_id(self):
return self.get_pref('track_detection', 'last_selected_track_id')
def get_last_selected_track_timestamp(self):
return self.get_pref_int('track_detection', 'last_selected_track_timestamp')
def set_last_selected_track(self, track_id, timestamp):
self.set_pref('track_detection', 'last_selected_track_id', track_id)
self.set_pref('track_detection', 'last_selected_track_timestamp', timestamp)
@property
def datastore_location(self):
return os.path.join(self.data_dir, 'datastore.sq3')
def save(self, *largs):
'''
Saves the current configuration
'''
with open(self.prefs_file, 'w+') as prefs_file:
data = self.to_json()
prefs_file.write(data)
def set_config_defaults(self):
'''
Set defaults for preferences
'''
# Base system preferences
self.config.adddefaultsection('help')
self.config.adddefaultsection('preferences')
self.config.setdefault('preferences', 'distance_units', 'miles')
self.config.setdefault('preferences', 'temperature_units', 'Fahrenheit')
self.config.setdefault('preferences', 'show_laptimes', 1)
self.config.setdefault('preferences', 'startup_screen', 'Home Page')
default_user_files_dir = self.user_files_dir
self.config.setdefault('preferences', 'config_file_dir', default_user_files_dir)
self.config.setdefault('preferences', 'firmware_dir', default_user_files_dir)
self.config.setdefault('preferences', 'import_datalog_dir', default_user_files_dir)
self.config.setdefault('preferences', 'first_time_setup', '1')
#.........这里部分代码省略.........
示例10: ConfigParser
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout
from kivy.uix.slider import Slider
from kivy.config import ConfigParser
from scripts.EdsNotify import EdsNotify
import commands
import platform
import urllib
devices = []
config = ConfigParser()
config.read('%s/eds.ini' % Usr)
try:
get_device = config.get("Source", "device")
except:
get_device = "none"
try:
get_branch = config.get("Source", "branch")
except:
get_branch = "none"
try:
make_jobs = config.get("Source", "make")
except:
make_jobs = numprocs
try:
sync_jobs = config.get("Source", "sync")
示例11: UserPrefs
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class UserPrefs(EventDispatcher):
_schedule_save = None
_prefs_dict = {'range_alerts': {}, 'gauge_settings':{}}
store = None
prefs_file_name = 'prefs.json'
prefs_file = None
config = None
data_dir = '.'
user_files_dir = '.'
def __init__(self, data_dir, user_files_dir, save_timeout=2, **kwargs):
self.data_dir = data_dir
self.user_files_dir = user_files_dir
self.prefs_file = path.join(self.data_dir, self.prefs_file_name)
self.load()
self._schedule_save = Clock.create_trigger(self.save, save_timeout)
def set_range_alert(self, key, range_alert):
self._prefs_dict["range_alerts"][key] = range_alert
self._schedule_save()
def get_range_alert(self, key, default=None):
return self._prefs_dict["range_alerts"].get(key, default)
def set_gauge_config(self, gauge_id, channel):
self._prefs_dict["gauge_settings"][gauge_id] = channel
self._schedule_save()
def get_gauge_config(self, gauge_id):
return self._prefs_dict["gauge_settings"].get(gauge_id, False)
def save(self, *largs):
with open(self.prefs_file, 'w+') as prefs_file:
data = self.to_json()
prefs_file.write(data)
def set_config_defaults(self):
self.config.adddefaultsection('preferences')
self.config.setdefault('preferences', 'distance_units', 'miles')
self.config.setdefault('preferences', 'temperature_units', 'Fahrenheit')
self.config.setdefault('preferences', 'show_laptimes', 1)
self.config.setdefault('preferences', 'startup_screen', 'Home Page')
default_user_files_dir = self.user_files_dir
self.config.setdefault('preferences', 'config_file_dir', default_user_files_dir )
self.config.setdefault('preferences', 'firmware_dir', default_user_files_dir )
self.config.setdefault('preferences', 'first_time_setup', True)
self.config.setdefault('preferences', 'send_telemetry', False)
self.config.setdefault('preferences', 'last_dash_screen', 'gaugeView')
def load(self):
print("the data dir " + self.data_dir)
self.config = ConfigParser()
self.config.read(os.path.join(self.data_dir, 'preferences.ini'))
self.set_config_defaults()
self._prefs_dict = {'range_alerts': {}, 'gauge_settings':{}}
try:
with open(self.prefs_file, 'r') as data:
content = data.read()
content_dict = json.loads(content)
if content_dict.has_key("range_alerts"):
for name, settings in content_dict["range_alerts"].iteritems():
self._prefs_dict["range_alerts"][name] = Range.from_dict(settings)
if content_dict.has_key("gauge_settings"):
for id, channel in content_dict["gauge_settings"].iteritems():
self._prefs_dict["gauge_settings"][id] = channel
except Exception:
pass
def get_pref(self, section, option):
return self.config.get(section, option)
def set_pref(self, section, option, value):
self.config.set(section, option, value)
self.config.write()
def to_json(self):
data = {'range_alerts': {}, 'gauge_settings':{}}
for name, range_alert in self._prefs_dict["range_alerts"].iteritems():
data["range_alerts"][name] = range_alert.to_dict()
for id, channel in self._prefs_dict["gauge_settings"].iteritems():
data["gauge_settings"][id] = channel
return json.dumps(data)
示例12: PlatformApp
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class PlatformApp(App):
title = ''
icon = 'images/4_pointd.png'
use_kivy_settings = False
def settings(self, instance): # settings panel
if instance.pos[0] == 0:
self.btnal.pos = (self.zoom[0], height-self.zoom[1]*1.5)
self.btnal.text = '<'
self.parent.add_widget(self.ui.al)
elif instance.pos[0] == self.zoom[0]:
self.btnal.pos = (0, height-self.zoom[1]*1.5)
self.btnal.text = '>'
self.parent.remove_widget(self.ui.al)
def color_choose(self, instance): # colours/tile panel
if instance.pos[0] == width-self.zoom[0]/2:
self.btnar.pos = (width-self.zoom[0]*1.5, height-self.zoom[1]*1.5)
self.btnar.text = '>'
self.parent.add_widget(self.ui.ar)
elif instance.pos[0] == width-self.zoom[0]*1.5:
self.btnar.pos = (width-self.zoom[0]/2, height-self.zoom[1]*1.5)
self.btnar.text = '<'
self.parent.remove_widget(self.ui.ar)
self.ui.ar.clear_widgets()
self.ui.ar.add_widget(self.ui.ac)
self.grid.refresh_screen()
def build(self):
self.config = ConfigParser()
self.config.read(self.directory + '/' + 'config.ini')
self.parent = Widget()
self.parent.canvas.clear()
self.parent.canvas.add(Color(0, 0, 0))
self.parent.canvas.add(Rectangle(size=(width, height)))
self.grid = Platform_draw()
self.ui = UI()
self.grid.ui = self.ui
self.ui.grid = self.grid
try:
zoom = int(self.config.get('platform', 'zoom'))
self.grid.zoom = (zoom, zoom)
except:
self.grid.zoom = (height/12, height/12)
try:
gridR = int(self.config.get('colors', 'r'))
except:
gridR = 0
try:
gridG = int(self.config.get('colors', 'g'))
except:
gridG = 0
try:
gridB = int(self.config.get('colors', 'b'))
except:
gridB = 1
self.grid.gridColor = (gridR/255.0, gridG/255.0, gridB/255.0)
self.grid.directory = self.directory
self.grid.upper = self
self.ui.upper = self
self.grid.on_startup()
self.ui.on_startup()
self.grid.lat, self.grid.longit, self.grid.lines = set_zoom([], self.grid.zoom)
self.zoom = self.grid.size
#adds the main classes
self.parent.add_widget(self.grid)
self.parent.add_widget(self.ui)
# creates buttons
self.btnar = Button(text = '<', pos = (width-self.zoom[0]/2, height-self.zoom[1]*1.5), size=(self.zoom[0]/2, self.zoom[1]))
self.btnal = Button(text = '>', pos = (0, height-self.zoom[1]*1.5), size=(self.zoom[0]/2, self.zoom[1]))
self.zoom_slider = Slider(orientation = 'horizontal', size = (width - height/3, height/12), pos = (height/6, height-height/12), max = height/6, min = 20, value = self.zoom[1], step = 1)
# gives grid a referance to the zoom slider, (for loading)
self.grid.zoom_slider = self.zoom_slider
self.btnal.bind(on_release = self.settings)
self.btnar.bind(on_release = self.color_choose)
self.zoom_slider.bind(on_touch_move = self.ui.value_zoom)
# adds buttons to screen
self.parent.add_widget(self.btnal)
self.parent.add_widget(self.btnar)
self.parent.add_widget(self.zoom_slider)
return self.parent
def build_settings(self, settings):
settings.add_json_panel('Defaults', self.config, self.directory + '/' + 'settings.json')
def on_config_change(self, config, section, key, value):
if config is self.config:
token = (section, key)
if token == ('platform', 'zoom'):
#.........这里部分代码省略.........
示例13: DuplicatorApp
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class DuplicatorApp(App):
#icon = 'icon.png'
title = 'Duplicator - Ultimate 3D Printing App'
#use_kivy_settings = False
sm = 0
gcode = None
'''
def build_config(self, config):
config.setdefaults('general',
{
'app_background_color': '000000',
'app_width': '640'
}
)
config.setdefaults('printer',
{
'printer_com_port': '/dev/tty.usbmodem1411',
'printer_com_speed': '115200',
'printer_extruder_count': '2',
'printer_heated_bed': '70',
'printer_extruder_1_temp': '220',
'printer_extruder_2_temp': '220',
'printer_bed_temp': '70'
}
)
'''
def build_settings(self, settings):
settings.add_json_panel('General Panel', self.config, join(dirname(__file__),'settings/settings_general.json' ) )
settings.add_json_panel('Printer panel', self.config, join(dirname(__file__),'settings/settings_printer.json') )
settings.add_json_panel('Scanner panel', self.config, join(dirname(__file__),'settings/settings_scanner.json') )
def build(self):
self.config = ConfigParser()
self.config.read(join( dirname(__file__),'duplicator.ini') )
print( self.config.get('general','app_background_color') )
#if not self.config.has_section("general"):
# self.config.add_section("general")
self.activeprinter = None
self.printer_pause = 0
self.sm = ScreenManager()
self.sm.add_widget(MenuScreen(name='Menu'))
self.sm.add_widget(PrintScreen(name='Print'))
self.sm.add_widget(ScanScreen(name='Scan'))
self.sm.add_widget(ShareScreen(name='Share'))
self.sm.add_widget(ConfigScreen(name='Config'))
self.sm.add_widget(PlaterScreen(name='Plater'))
self.sm.add_widget(ViewScreen(name='View'))
self.sm.add_widget(FileGcodeLoadScreen(name='FileGcodeLoad'))
self.menu_bar = Factory.MenuBar()
self.sm.get_screen('Menu').ids.window_layout.add_widget(self.menu_bar)
self.menu_bar.ids.short_message.text = 'Duplicator Started\nReady for action.'
self.cam1 = cv2.VideoCapture(0)
return self.sm
def switchtoscreen(self,ScreenName):
if ScreenName == 'Menu':
self.sm.transition = SlideTransition(direction='left')
elif ScreenName == 'FileGcodeLoad':
self.sm.transition = SlideTransition(direction='up')
else:
if(self.sm.current=='FileGcodeLoad'):
self.sm.transition = SlideTransition(direction='down')
else:
self.sm.transition = SlideTransition(direction='right')
#print(self.sm.current)
print(ScreenName)
if(ScreenName != 'FileGcodeLoad') and (self.sm.current!='FileGcodeLoad'):
self.sm.get_screen(self.sm.current).ids.window_layout.remove_widget(self.menu_bar)
self.sm.get_screen(ScreenName).ids.window_layout.add_widget(self.menu_bar)
self.sm.current = ScreenName
def connectprinter(self,activeswitch):
if activeswitch:
self.menu_bar.ids.short_message.text = 'disconnecting....'
try:
self.activeprinter.disconnect()
self.menu_bar.ids.short_message.text = 'Done'
self.sm.get_screen('Print').ids.connectprinterswitch.active=0
self.activeprinter = None
self.menu_bar.ids.indicator_printer.color = (0,0,0,.3)
except:
#.........这里部分代码省略.........
示例14: NuBippyApp
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
class NuBippyApp(App):
"""
The application Class for Bippy
"""
def __init__(self, **kwargs):
super(NuBippyApp, self).__init__(**kwargs)
self.isPopup = False
self.show_info = False
self.use_kivy_settings = False
# load config file
# we don't display the settings panel, changes can be made manually to the ini file
self.config = ConfigParser()
self.config.read('nubippy.ini')
# Set the language and load the language file
self.language = self.config.get('Language', 'active_language')
try:
self.lang = json.load(open('res/json/languages/' + self.language + '.json', 'r'))
except ValueError as e:
print('')
print('##################################################################')
print('')
print('There was an Error loading the ' + self.language + ' language file.')
print('')
print(str(e))
print('')
print('##################################################################')
raise SystemExit
return
def build(self):
"""
Build the Main Application Window
"""
# Root widget is a Box Layout
self.root = BoxLayout(orientation='vertical')
self.infoText = TextInput(readonly=True)
self.mainScreenManager = ScreenManager(transition=SlideTransition(direction='left'))
# Add the Action Bar
self.topActionBar = TopActionBar()
self.root.add_widget(self.topActionBar)
# Add the Scroll View For displaying Info
self.infoScrollView = ScrollView(size_hint_y=None, height=0, border=1)
self.infoScrollView.add_widget(self.infoText)
self.root.add_widget(self.infoScrollView)
#Add the screenManager
Builder.load_file('screens/HomeScreen.kv')
self.homeScreen = HomeScreen.HomeScreen(self)
Builder.load_file('screens/PrivateKeyScreen.kv')
self.privateKeyScreen = PrivateKeyScreen.PrivateKeyScreen(self)
Builder.load_file('screens/VanityScreen.kv')
self.vanityScreen = VanityScreen.VanityScreen(self)
Builder.load_file('screens/ResultsScreen.kv')
self.resultsScreen = ResultsScreen.ResultsScreen(self)
NuBippyApp.mainScreenManager.add_widget(self.homeScreen)
NuBippyApp.mainScreenManager.add_widget(self.privateKeyScreen)
NuBippyApp.mainScreenManager.add_widget(self.vanityScreen)
NuBippyApp.mainScreenManager.add_widget(self.resultsScreen)
self.root.add_widget(NuBippyApp.mainScreenManager)
return self.root
def set_info(self, info):
"""
Read the info from the <language>.json file and set it as the info text
"""
self.infoText.text = NuBippyApp.get_string(info)
return
def toggle_info(self):
"""
This method toggles the visibility of the 'info' space
It also handles the transition animation of the opening and closing
"""
self.show_info = not self.show_info
if self.show_info:
height = self.root.height * .3
else:
height = 0
Animation(height=height, d=.3, t='out_quart').start(self.infoScrollView)
self.topActionBar.infoButton.state = 'normal'
def get_currency_code(self, currencyLongName):
"""
For the given currency long name return the currency abbreviation
"""
for cur in self.currencies:
if cur['longName'] == currencyLongName:
return cur['currency']
def reset_ui(self):
#.........这里部分代码省略.........
示例15: ConfigParser
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get [as 别名]
CODES_DICT = {s:dict(CODES.items(s)) for s in CODES.sections()}
NUMBERS = ConfigParser()
NUMBERS.read('numbers.ini')
NUMBERS_DICT = {s:dict(NUMBERS.items(s)) for s in NUMBERS.sections()}
LANGUAGES = ConfigParser()
LANGUAGES.read('languages.ini')
LANGUAGES_DICT = {s:dict(LANGUAGES.items(s)) for s in LANGUAGES.sections()}
# ===========================
# Load the Sound Effects
# ===========================
Sound_Click = SoundLoader.load(config.get('Sounds','Sound_Click'))
Sound_Delete = SoundLoader.load(config.get('Sounds','Sound_Delete'))
Sound_Error = SoundLoader.load(config.get('Sounds','Sound_Error'))
Sound_Door = SoundLoader.load(config.get('Sounds','Sound_Door'))
Sound_RingerButton = SoundLoader.load(config.get('Sounds','Sound_RingerButton'))
Sound_Ringer = SoundLoader.load(config.get('Sounds','Sound_Ringer'))
Sound_Code = SoundLoader.load(config.get('Sounds','Sound_Code'))
Sound_System = SoundLoader.load(config.get('Sounds','Sound_System'))
Sound_Settings = SoundLoader.load(config.get('Sounds','Sound_Settings'))
# =======================