本文整理汇总了Python中theme.Theme类的典型用法代码示例。如果您正苦于以下问题:Python Theme类的具体用法?Python Theme怎么用?Python Theme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Theme类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
global screen
print("Nerd Tabu")
# Parse command line
parser = argparse.ArgumentParser()
parser.add_argument('quizfile', type=argparse.FileType('r'), help='Name of the quiz file')
parser.add_argument('teamA', nargs='?', metavar='teamname_A', default='Team A', help='Name of team A')
parser.add_argument('teamB', nargs='?', metavar='teamname_B', default='Team B', help='Name of team B')
parser.add_argument('-d', '--datadir', default='.', help='Resource directory')
parser.add_argument('-f', '--fullscreen', help='Run fullscreen', action='store_true')
args = parser.parse_args()
# Update settings
settings = Settings(args.quizfile, args.datadir)
settings.teams = [ args.teamA, args.teamB ]
theme = Theme(args.datadir)
# Initial game data
cards = settings.get_random_cards()
current_team = 0
# Main game loop
pygame.init()
if args.fullscreen:
# screen = pygame.display.set_mode(theme.screen_size, pygame.FULLSCREEN)
screen = pygame.display.set_mode(theme.screen_size, pygame.RESIZABLE | pygame.NOFRAME)
else:
screen = pygame.display.set_mode(theme.screen_size)
theme.load_data()
while len(cards)>0:
team_get_ready(theme, settings, current_team)
play_round(theme, settings, current_team, cards)
current_team = (current_team + 1) % len(settings.teams)
show_final_scores(theme, settings)
pygame.quit()
示例2: read_config
def read_config(self, path):
"""parse alot's config file from path"""
spec = os.path.join(DEFAULTSPATH, 'alot.rc.spec')
newconfig = read_config(path, spec,
checks={'mail_container': mail_container,
'force_list': force_list,
'align': align_mode,
'attrtriple': attr_triple,
'gpg_key_hint': gpg_key})
self._config.merge(newconfig)
hooks_path = os.path.expanduser(self._config.get('hooksfile'))
try:
self.hooks = imp.load_source('hooks', hooks_path)
except:
logging.debug('unable to load hooks file:%s' % hooks_path)
if 'bindings' in newconfig:
newbindings = newconfig['bindings']
if isinstance(newbindings, Section):
self._bindings.merge(newbindings)
# themes
themestring = newconfig['theme']
themes_dir = self._config.get('themes_dir')
if themes_dir:
themes_dir = os.path.expanduser(themes_dir)
else:
configdir = os.environ.get('XDG_CONFIG_HOME',
os.path.expanduser('~/.config'))
themes_dir = os.path.join(configdir, 'alot', 'themes')
logging.debug(themes_dir)
# if config contains theme string use that
if themestring:
if not os.path.isdir(themes_dir):
err_msg = 'cannot find theme %s: themes_dir %s is missing'
raise ConfigError(err_msg % (themestring, themes_dir))
else:
theme_path = os.path.join(themes_dir, themestring)
try:
self._theme = Theme(theme_path)
except ConfigError as e:
err_msg = 'Theme file %s failed validation:\n'
raise ConfigError((err_msg % themestring) + e.message)
# if still no theme is set, resort to default
if self._theme is None:
theme_path = os.path.join(DEFAULTSPATH, 'default.theme')
self._theme = Theme(theme_path)
self._accounts = self._parse_accounts(self._config)
self._accountmap = self._account_table(self._accounts)
示例3: __init__
def __init__(self, group, class_group=None,
desktop_entry=None, identifier=None):
self.dockbar_r = weakref.ref(group.dockbar_r())
self.theme = Theme()
self.globals = Globals()
connect(self.globals, "color-changed", self.reset_surfaces)
self.desktop_entry = desktop_entry
self.identifier = identifier
self.class_group = class_group
# Setting size to something other than zero to
# avoid crashes if surface_update() is runned
# before the size is set.
self.size = 15
self.icon = None
self.surfaces = {}
self.average_color = None
self.max_win_nr = self.theme.get_windows_cnt()
self.types_in_theme = 0
for type in self.theme.get_types():
if not type in self.TYPE_DICT:
continue
self.types_in_theme = self.types_in_theme | self.TYPE_DICT[type]
示例4: __init__
def __init__(self):
"""
Attributes
----------
metadata: dict
presentation metadata; each element of the dictionary if a dict with ['value', 'user'] items: value contains
the metadata value and user indicates if the value comes from user (if True) or from defaults (if False).
"""
self.reset()
self.metadata = {'title': Metadata(name='title', value=''),
'subtitle': Metadata(name='subtitle', value=''),
'authors': Metadata(name='authors', value=[]),
'authors_short': Metadata(name='authors_short', value=[]),
'emails': Metadata(name='emails', value=[]),
'affiliations': Metadata(name='affiliations', value=[]),
'affiliations_short': Metadata(name='affiliations_short', value=[]),
'logo': Metadata(name='logo', value=''),
'timer': Metadata(name='timer', value=''),
'location': Metadata(name='location', value=''),
'location_short': Metadata(name='location_short', value=''),
'date': Metadata(name='date', value=''),
'conference': Metadata(name='conference', value=''),
'conference_short': Metadata(name='conference_short', value=''),
'session': Metadata(name='session', value=''),
'session_short': Metadata(name='session_short', value=''),
'max_time': Metadata(name='max_time', value='25'),
'total_slides_number': Metadata(name='total_slides_number', value=''),
'dirs_to_copy': Metadata(name='dirs_to_copy', value=[]),
'toc': Metadata(name='toc', value=OrderedDict()),
'toc_depth': Metadata(name='toc_depth', value='2'),
'chaptertitle': Metadata(name='chaptertitle', value=''),
'chapternumber': Metadata(name='chapternumber', value=''),
'sectiontitle': Metadata(name='sectiontitle', value=''),
'sectionnumber': Metadata(name='sectionnumber', value=''),
'subsectiontitle': Metadata(name='subsectiontitle', value=''),
'subsectionnumber': Metadata(name='subsectionnumber', value=''),
'slidetitle': Metadata(name='slidetitle', value=''),
'slidenumber': Metadata(name='slidenumber', value=''),
'css_overtheme': Metadata(name='css_overtheme', value=[]),
'custom': Metadata(name='custom-[0-9]*', value='')}
self.theme = Theme()
self.parser = Parser()
self.chapters = []
self.position = Position()
return
示例5: __init__
def __init__(self, number, position=None, title=None, contents=None):
""""
Paramters
---------
number: int
slide global numeration
position: dict
position dictionary containing {'x': posx, 'y': posy, 'z': posz, 'rotx': rotx, 'roty': roty, 'rotz': rotz, 'scale': scaling}
title: str
contents: str
"""
self.number = number
self.position = None
self.set_position(position)
self.title = title
self.contents = contents
self.overtheme = Theme()
return
示例6: __init__
def __init__(self, liststore):
self.liststore = liststore
self.gui = gui = Gtk.Builder()
gui.add_from_file(SHARED_DATA_FILE("gfeedline.glade"))
self.window = window = gui.get_object("main_window")
self.column = MultiColumnDict(gui) # multi-columns for Notebooks
self.theme = Theme()
self.font = FontSet()
self.notification = StatusNotification(liststore)
dnd_list = [Gtk.TargetEntry.new("text/uri-list", 0, 1), Gtk.TargetEntry.new("text/x-moz-url", 0, 4)]
window.drag_dest_set(Gtk.DestDefaults.ALL, dnd_list, Gdk.DragAction.COPY)
target = Gtk.TargetList.new([])
target.add(Gdk.Atom.intern("text/x-moz-url", False), 0, 4)
target.add(Gdk.Atom.intern("text/uri-list", False), 0, 1)
window.drag_dest_set_target_list(target)
window.connect("drag-data-received", self.on_drag_data_received)
SETTINGS.connect("changed::window-sticky", self.on_settings_sticky_change)
self.on_settings_sticky_change(SETTINGS, "window-sticky")
SETTINGS_VIEW.connect("changed::theme", self.on_settings_theme_change)
self.on_settings_theme_change(SETTINGS_VIEW, "theme")
is_multi_column = SETTINGS_VIEW.get_boolean("multi-column")
menuitem_multicolumn = gui.get_object("menuitem_multicolumn")
menuitem_multicolumn.set_active(is_multi_column)
menuitem_update = MenuItemUpdate(gui, liststore)
x, y, w, h = self._get_geometry_from_settings()
# window.show() # for wrong position when auto-start
if x >= 0 and y >= 0:
window.move(x, y)
window.resize(w, h)
window.show()
gui.connect_signals(self)
示例7: __init__
def __init__(self, parent, connection):
BasePane.__init__(
self, parent, connection, style=wx.TE_AUTO_URL | wx.TE_READONLY | wx.TE_NOHIDESEL | wx.TE_MULTILINE
)
# state toggles for ANSI processing
self.intensity = ""
self.inverse = False
self.theme = Theme()
# TODO - this probably should be a preference, but for now, this is the
# least-bad default behavior.
self.Bind(wx.EVT_SIZE, self.on_size)
self.Bind(wx.EVT_SET_FOCUS, self.focus_input)
self.Bind(wx.EVT_TEXT_URL, self.process_url_click)
self.Bind(wx.EVT_MIDDLE_DOWN, self.connection.input_pane.paste_from_selection)
self.Bind(rtc.EVT_RICHTEXT_SELECTION_CHANGED, self.copy_from_selection)
self.Bind(EVT_ROW_COL_CHANGED, self.on_row_col_changed)
示例8: __init__
def __init__(self, alot_rc=None, notmuch_rc=None, theme=None):
"""
:param alot_rc: path to alot's config file
:type alot_rc: str
:param notmuch_rc: path to notmuch's config file
:type notmuch_rc: str
:theme: path to initially used theme file
:type theme: str
"""
self.hooks = None
self._mailcaps = mailcap.getcaps()
theme_path = theme or os.path.join(DEFAULTSPATH, 'default.theme')
self._theme = Theme(theme_path)
bindings_path = os.path.join(DEFAULTSPATH, 'default.bindings')
self._bindings = ConfigObj(bindings_path)
self._config = ConfigObj()
self._accounts = None
self._accountmap = None
self.read_config(alot_rc)
self.read_notmuch_config(notmuch_rc)
示例9: _get_viewers
def _get_viewers ( self ):
from theme import Theme
from image_slice_viewer import ImageSliceViewer
slicer = self.slicer
theme = Theme.decode_image_slice( slicer.encoded, slicer.image )
result = [
ImageSliceViewer(
name = name,
image_slice = info.image_slice )
for name, info in (
( ( 'Bottom Label', 'Top Label' )[ theme.on_top ],
theme.horizontal ),
( ( 'Right Label', 'Left Label' )[ theme.on_left ],
theme.vertical ),
( 'Body', theme.body ) )
if info is not None
]
result.insert( 0, ImageSliceViewer( name = 'Original',
image = slicer.image ) )
return result
示例10: __init__
def __init__(self, parent=None):
super(MyElement, self).__init__()
self.setObjectName('mainObject')
self._users = []
self._index = 0
self._myTheme = Theme()
self._myColor = self._myTheme.getTheme()
self.mainProc = QProcess()
self.secondProc = QProcess()
self.mainProc.finished.connect(self.finishProc)
self.mainProc.started.connect(self.startProc)
self.secondProc.finished.connect(self.secondFinishProc)
self.secondProc.started.connect(self.startProc)
self.auth = Auth()
self._isiPesan = ""
self._judulPesan = "Error"
self._overlay = ""
self._isLock = False
self._hasRegister = False
self._hasLogin = False
self._hasError = False
self._userListData = UserItemModel()
self._userListData.addRootElement()
self.addNewUser()
示例11: reload
def reload(self, event=None, data=None):
# Remove all old groupbuttons from container.
for child in self.container.get_children():
self.container.remove(child)
if self.windows:
# Removes windows and unpinned group buttons
for win in self.screen.get_windows():
self.on_window_closed(None, win)
if self.groups is not None:
# Removes pinned group buttons
for group in self.groups:
group.hide_list()
group.icon_factory.remove()
del self.groups
del self.windows
if self.theme:
self.theme.remove()
gc.collect()
print "Dockbarx reload"
self.groups = GroupList()
self.windows = {}
# Get the monitor on which dockbarx is.
gdk_screen = gtk.gdk.screen_get_default()
win = self.container.window
if win is not None:
self.monitor = gdk_screen.get_monitor_at_window(win)
#--- Generate Gio apps
self.apps_by_id = {}
self.app_ids_by_exec = {}
self.app_ids_by_name = {}
self.app_ids_by_longname = {}
self.wine_app_ids_by_program = {}
for app in gio.app_info_get_all():
id = app.get_id()
id = id[:id.rfind('.')].lower()
name = u""+app.get_name().lower()
exe = app.get_executable()
if exe:
self.apps_by_id[id] = app
if id[:5] == 'wine-':
try:
cmd = u""+app.get_commandline().lower()
except AttributeError:
# Older versions of gio doesn't have get_comandline.
cmd = u""
if cmd.find('.exe') > 0:
program = cmd[:cmd.rfind('.exe')+4]
program = program[program.rfind('\\')+1:]
self.wine_app_ids_by_program[program] = id
if name.find(' ')>-1:
self.app_ids_by_longname[name] = id
else:
self.app_ids_by_name[name] = id
if exe not in ('sudo','gksudo',
'java','mono',
'ruby','python'):
if exe[0] == '/':
exe = exe[exe.rfind('/')+1:]
self.app_ids_by_exec[exe] = id
else:
self.app_ids_by_exec[exe] = id
try:
if self.theme is None:
self.theme = Theme()
else:
self.theme.on_theme_changed()
except NoThemesError, details:
print details
sys.exit(1)
示例12: IconFactory
class IconFactory():
"""IconFactory finds the icon for a program and prepares the cairo surface."""
icon_theme = gtk.icon_theme_get_default()
# Constants
# Icon types
SOME_MINIMIZED = 1<<4
ALL_MINIMIZED = 1<<5
LAUNCHER = 1<<6
# Icon effects
MOUSE_OVER = 1<<7
MOUSE_BUTTON_DOWN = 1<<8
NEEDS_ATTENTION = 1<<9
BLINK = 1<<10
# ACTIVE_WINDOW
ACTIVE = 1<<11
LAUNCH_EFFECT = 1<<12
# Double width/height icons for drag and drop situations.
DRAG_DROPP_START = 1<<13
DRAG_DROPP_END = 1<<14
TYPE_DICT = {"some_minimized":SOME_MINIMIZED,
"all_minimized":ALL_MINIMIZED,
"launcher":LAUNCHER,
"mouse_over":MOUSE_OVER,
"needs_attention":NEEDS_ATTENTION,
"blink":BLINK,
"active":ACTIVE,
"launching":LAUNCH_EFFECT,
"mouse_button_down":MOUSE_BUTTON_DOWN}
def __init__(self, group, class_group=None,
desktop_entry=None, identifier=None):
self.dockbar_r = weakref.ref(group.dockbar_r())
self.theme = Theme()
self.globals = Globals()
connect(self.globals, "color-changed", self.reset_surfaces)
self.desktop_entry = desktop_entry
self.identifier = identifier
self.class_group = class_group
# Setting size to something other than zero to
# avoid crashes if surface_update() is runned
# before the size is set.
self.size = 15
self.icon = None
self.surfaces = {}
self.average_color = None
self.max_win_nr = self.theme.get_windows_cnt()
self.types_in_theme = 0
for type in self.theme.get_types():
if not type in self.TYPE_DICT:
continue
self.types_in_theme = self.types_in_theme | self.TYPE_DICT[type]
def remove(self):
del self.desktop_entry
del self.class_group
del self.icon
del self.surfaces
del self.theme
def set_desktop_entry(self, desktop_entry):
self.desktop_entry = desktop_entry
self.surfaces = {}
del self.icon
self.icon = None
def set_class_group(self, class_group):
if not self.desktop_entry and not self.class_group:
self.surfaces = {}
del self.icon
self.icon = None
self.class_group = class_group
def set_size(self, size):
if size <= 0:
# To avoid chrashes.
size = 15
self.size = size
self.surfaces = {}
self.average_color = None
def get_size(self):
return self.size
def get_icon(self, size):
return self.__find_icon_pixbuf(size)
def reset_icon(self):
self.icon = None
def reset_surfaces(self, arg=None):
self.surfaces = {}
self.average_color = None
def surface_update(self, type = 0):
# Checks if the requested pixbuf is already
#.........这里部分代码省略.........
示例13: MainWindow
class MainWindow(object):
def __init__(self, liststore):
self.liststore = liststore
self.gui = gui = Gtk.Builder()
gui.add_from_file(SHARED_DATA_FILE("gfeedline.glade"))
self.window = window = gui.get_object("main_window")
self.column = MultiColumnDict(gui) # multi-columns for Notebooks
self.theme = Theme()
self.font = FontSet()
self.notification = StatusNotification(liststore)
dnd_list = [Gtk.TargetEntry.new("text/uri-list", 0, 1), Gtk.TargetEntry.new("text/x-moz-url", 0, 4)]
window.drag_dest_set(Gtk.DestDefaults.ALL, dnd_list, Gdk.DragAction.COPY)
target = Gtk.TargetList.new([])
target.add(Gdk.Atom.intern("text/x-moz-url", False), 0, 4)
target.add(Gdk.Atom.intern("text/uri-list", False), 0, 1)
window.drag_dest_set_target_list(target)
window.connect("drag-data-received", self.on_drag_data_received)
SETTINGS.connect("changed::window-sticky", self.on_settings_sticky_change)
self.on_settings_sticky_change(SETTINGS, "window-sticky")
SETTINGS_VIEW.connect("changed::theme", self.on_settings_theme_change)
self.on_settings_theme_change(SETTINGS_VIEW, "theme")
is_multi_column = SETTINGS_VIEW.get_boolean("multi-column")
menuitem_multicolumn = gui.get_object("menuitem_multicolumn")
menuitem_multicolumn.set_active(is_multi_column)
menuitem_update = MenuItemUpdate(gui, liststore)
x, y, w, h = self._get_geometry_from_settings()
# window.show() # for wrong position when auto-start
if x >= 0 and y >= 0:
window.move(x, y)
window.resize(w, h)
window.show()
gui.connect_signals(self)
def on_drag_data_received(self, widget, context, x, y, selection, info, time):
text, image_file = DnDSelection.parse(info, selection, True)
if text or image_file:
updatewindow = UpdateWindow(self)
if text:
updatewindow.text_buffer.set_text(text)
else:
updatewindow.set_upload_media(image_file)
def get_notebook(self, group_name):
if not SETTINGS_VIEW.get_boolean("multi-column"):
group_name = "dummy for single column"
if group_name in self.column:
notebook = self.column.get(group_name)
else:
notebook = FeedNotebook(self.column, group_name, self.liststore)
self.column.add(group_name, notebook)
return notebook
def toggle_multicolumn_mode(self):
for row in self.liststore:
notebook = self.get_notebook(row[Column.GROUP])
view = row[Column.API].view
view.force_remove()
view.append(notebook, -1)
reactor.callLater(0.1, self._jump_all_tabs_to_bottom, self.theme.is_ascending())
def _jump_all_tabs_to_bottom(self, is_bottom=True):
for notebook in self.column.values():
notebook.jump_all_tabs_to_bottom(is_bottom)
def change_font(self, font=None, size=None):
for notebook in self.column.values():
notebook.change_font(font, size)
def delete_status(self, status_id):
js = 'hideStatus("%s")' % status_id
for notebook in self.column.values():
notebook.exec_js_all_views(js)
def _get_geometry_from_settings(self):
x = SETTINGS_GEOMETRY.get_int("window-x")
y = SETTINGS_GEOMETRY.get_int("window-y")
w = SETTINGS_GEOMETRY.get_int("window-width")
h = SETTINGS_GEOMETRY.get_int("window-height")
return x, y, w, h
def on_window_leave_notify_event(self, widget, event):
#.........这里部分代码省略.........
示例14: reset
def reset(cls):
"""Reset to default state."""
cls.chapters_number = 0
Theme.reset()
Chapter.reset()
示例15: parse
def parse(self, config, source):
"""Parse presentation from source stream.
Parameters
----------
config : MatisseConfig
MaTiSSe configuration
source: str
"""
complete_source = self.parser.includes(source=source)
self.__get_metadata(source=complete_source)
self.__get_theme(source=complete_source)
new_theme = Theme()
new_theme.set_from(other=self.theme)
tokens = self.parser.tokenize(source=complete_source)
self.__check_bad_sectioning(tokens=tokens)
chapters_number = 0
sections_number = 0
subsections_number = 0
slides_number = 0
titlepage_inserted = False
for chap in tokens['chapters']:
chapters_number += 1
slide_local_numbers = [0, 0, 0]
if chap['match'].group('expr'):
chapter = Chapter(number=chapters_number, title=chap['match'].group('expr'))
else:
chapter = Chapter(number=chapters_number, title='')
for sec in tokens['sections']:
if sec['start'] >= chap['start'] and sec['start'] <= chap['end_next']:
sections_number += 1
slide_local_numbers[1] = 0
slide_local_numbers[2] = 0
section = Section(number=sections_number, title=sec['match'].group('expr'))
for subsec in tokens['subsections']:
if subsec['start'] >= sec['start'] and subsec['start'] <= sec['end_next']:
subsections_number += 1
slide_local_numbers[2] = 0
subsection = Subsection(number=subsections_number, title=subsec['match'].group('expr'))
for sld in tokens['slides']:
if '$titlepage' in sld['match'].group().lower() and not titlepage_inserted:
slide = Slide(number=0,
title='titlepage',
contents=complete_source[sld['end']:sld['end_next']])
slide.get_overtheme(parser=self.parser)
if slide.overtheme.copy_from_theme is not None and slide.overtheme.copy_from_theme:
slide.overtheme.copy_from(other=self.theme)
self.position.update_position(presentation_theme=self.theme, overtheme=slide.overtheme)
slide.set_position(position=self.position.position)
subsection.add_slide(slide=slide)
titlepage_inserted = True
else:
if sld['start'] >= subsec['start'] and sld['start'] <= subsec['end_next']:
slide_local_numbers[0] += 1
slide_local_numbers[1] += 1
slide_local_numbers[2] += 1
if slide_local_numbers[0] == 1 and config.toc_at_chap_beginning is not None:
slides_number += 1
self.position.update_position(presentation_theme=self.theme)
subsection.add_slide(slide=Slide(number=slides_number,
position=self.position.position,
title='Table of Contents',
contents='$toc[depth:' + str(config.toc_at_chap_beginning) + ']'))
if slide_local_numbers[1] == 1 and config.toc_at_sec_beginning is not None:
slides_number += 1
self.position.update_position(presentation_theme=self.theme)
subsection.add_slide(slide=Slide(number=slides_number,
position=self.position.position,
title='Table of Contents',
contents='$toc[depth:' + str(config.toc_at_sec_beginning) + ']'))
if slide_local_numbers[2] == 1 and config.toc_at_subsec_beginning is not None:
slides_number += 1
self.position.update_position(presentation_theme=self.theme)
subsection.add_slide(slide=Slide(number=slides_number,
position=self.position.position,
title='Table of Contents',
contents='$toc[depth:' + str(config.toc_at_subsec_beginning) + ']'))
slides_number += 1
slide = Slide(number=slides_number,
title=sld['match'].group('expr'),
contents=complete_source[sld['end']:sld['end_next']])
slide.get_overtheme(parser=self.parser)
if slide.overtheme.copy_from_theme is not None and slide.overtheme.copy_from_theme:
slide.overtheme.copy_from(other=self.theme)
self.position.update_position(presentation_theme=self.theme, overtheme=slide.overtheme)
slide.set_position(position=self.position.position)
subsection.add_slide(slide=slide)
section.add_subsection(subsection=subsection)
chapter.add_section(section=section)
self.__add_chapter(chapter=chapter)
self.metadata['total_slides_number'].update_value(value=str(Subsection.slides_number))