本文整理汇总了Python中pychess.Utils.IconLoader.get_pixbuf函数的典型用法代码示例。如果您正苦于以下问题:Python get_pixbuf函数的具体用法?Python get_pixbuf怎么用?Python get_pixbuf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_pixbuf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _init
def _init (cls):
def callback (widget, allocation):
cls.widgets["setupPositionFrame"].set_size_request(
523, allocation.height-4)
cls.widgets["setupPositionSidePanel"].connect_after("size-allocate", callback)
cls.castl = set()
cls.white = Gtk.Image.new_from_pixbuf(get_pixbuf("glade/white.png"))
cls.black = Gtk.Image.new_from_pixbuf(get_pixbuf("glade/black.png"))
cls.widgets["side_button"].set_image(cls.white)
cls.widgets["side_button"].connect("toggled", cls.side_button_toggled)
cls.widgets["moveno_spin"].connect("value-changed", cls.moveno_spin_changed)
cls.widgets["fifty_spin"].connect("value-changed", cls.fifty_spin_changed)
cls.widgets["woo"].connect("toggled", cls.castl_toggled, "K")
cls.widgets["wooo"].connect("toggled", cls.castl_toggled, "Q")
cls.widgets["boo"].connect("toggled", cls.castl_toggled, "k")
cls.widgets["booo"].connect("toggled", cls.castl_toggled, "q")
ep_store = Gtk.ListStore(str)
ep_store.append(["-"])
for f in reprFile:
ep_store.append([f])
epcombo = cls.widgets["ep_combo"]
epcombo.set_name("ep_combo")
epcombo.set_model(ep_store)
renderer_text = Gtk.CellRendererText()
cls.widgets["ep_combo"].pack_start(renderer_text, True)
cls.widgets["ep_combo"].add_attribute(renderer_text, "text", 0)
cls.widgets["ep_combo"].set_active(0)
cls.widgets["ep_combo"].connect("changed", cls.ep_combo_changed)
开发者ID:jcoffee,项目名称:pychess,代码行数:32,代码来源:newGameDialog.py
示例2: createPlayerUIGlobals
def createPlayerUIGlobals(discoverer):
global playerItems
global analyzerItems
global allEngineItems
playerItems = []
analyzerItems = []
allEngineItems = []
for variantClass in variants.values():
playerItems += [[(ipeople, _("Human Being"))]]
for engine in discoverer.getEngines():
name = engine["name"]
c = discoverer.getCountry(engine)
path = addDataPrefix("flags/%s.png" % c)
if c and os.path.isfile(path):
flag_icon = get_pixbuf(path)
else:
path = addDataPrefix("flags/unknown.png")
flag_icon = get_pixbuf(path)
allEngineItems.append((flag_icon, name))
for variant in discoverer.getEngineVariants(engine):
playerItems[variant] += [(flag_icon, name)]
if discoverer.is_analyzer(engine):
analyzerItems.append((flag_icon, name))
开发者ID:leogregianin,项目名称:pychess,代码行数:29,代码来源:newGameDialog.py
示例3: __init__
def __init__(self):
#GObject.GObject.__init__(self,0,0,0,0)
GObject.GObject.__init__(self)
self.widgets = widgets = uistuff.GladeWidgets("taskers.glade")
tasker = widgets["newGameTasker"]
tasker.unparent()
self.add(tasker)
combo = ToggleComboBox()
combo.addItem(_("White"), get_pixbuf("glade/white.png"))
combo.addItem(_("Black"), get_pixbuf("glade/black.png"))
combo.addItem(_("Random"), get_pixbuf("glade/random.png"))
combo.setMarkup("<b>", "</b>")
widgets["colorDock"].add(combo)
uistuff.keep(combo, "newgametasker_colorcombo")
widgets['yourColorLabel'].set_mnemonic_widget(combo)
# We need to wait until after engines have been discovered, to init the
# playerCombos. We use connect_after to make sure, that newGameDialog
# has also had time to init the constants we share with them.
self.playerCombo = ToggleComboBox()
widgets["opponentDock"].add(self.playerCombo)
discoverer.connect_after("all_engines_discovered",
self.__initPlayerCombo, widgets)
widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo)
def on_skill_changed(scale):
pix = newGameDialog.skillToIconLarge[int(scale.get_value())]
widgets["skillImage"].set_from_pixbuf(pix)
widgets["skillSlider"].connect("value-changed", on_skill_changed)
on_skill_changed(widgets["skillSlider"])
widgets["startButton"].connect("clicked", self.startClicked)
self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
开发者ID:vaj25,项目名称:pychess,代码行数:35,代码来源:TaskerManager.py
示例4: getIconByRating
def getIconByRating(cls, rating, size=16):
assert isinstance(rating, int), "rating not an int: %s" % str(rating)
if rating >= 1900:
return get_pixbuf("glade/16x16/weather-storm.png")
elif rating >= 1600:
return get_pixbuf("glade/16x16/weather-showers.png")
elif rating >= 1300:
return get_pixbuf("glade/16x16/weather-overcast.png")
elif rating >= 1000:
return get_pixbuf("glade/16x16/weather-few-clouds.png")
else:
return get_pixbuf("glade/16x16/weather-clear.png")
开发者ID:teacoffee2017,项目名称:pychess,代码行数:12,代码来源:FICSObjects.py
示例5: dock_panel_tab
def dock_panel_tab(title, desc, icon):
box = Gtk.Box()
pixbuf = get_pixbuf(icon, 16)
image = Gtk.Image.new_from_pixbuf(pixbuf)
label = Gtk.Label(label=title)
label.set_size_request(0, 0)
label.set_alignment(0, 1)
box.pack_start(image, False, False, 0)
box.pack_start(label, True, True, 0)
box.set_spacing(2)
box.show_all()
def cb(widget, x, y, keyboard_mode, tooltip, title, desc, filename):
table = Gtk.Table(2, 2)
table.set_row_spacings(2)
table.set_col_spacings(6)
table.set_border_width(4)
pixbuf = get_pixbuf(filename, 56)
image = Gtk.Image.new_from_pixbuf(pixbuf)
image.set_alignment(0, 0)
table.attach(image, 0, 1, 0, 2)
titleLabel = Gtk.Label()
titleLabel.set_markup("<b>%s</b>" % title)
titleLabel.set_alignment(0, 0)
table.attach(titleLabel, 1, 2, 0, 1)
descLabel = Gtk.Label(label=desc)
descLabel.props.wrap = True
table.attach(descLabel, 1, 2, 1, 2)
tooltip.set_custom(table)
table.show_all()
return True
box.props.has_tooltip = True
box.connect("query-tooltip", cb, title, desc, icon)
return box
开发者ID:bboutkov,项目名称:pychess,代码行数:35,代码来源:__init__.py
示例6: __init__
def __init__(self):
GObject.GObject.__init__(self)
self.widgets = widgets = uistuff.GladeWidgets("taskers.glade")
tasker = widgets["newGameTasker"]
tasker.unparent()
self.add(tasker)
startButton = self.widgets["startButton"]
startButton.set_name("startButton")
combo = Gtk.ComboBox()
uistuff.createCombo(combo, [
(get_pixbuf("glade/white.png"), _("White")),
(get_pixbuf("glade/black.png"), _("Black")),
(get_pixbuf("glade/random.png"), _("Random"))])
widgets["colorDock"].add(combo)
if combo.get_active() < 0:
combo.set_active(0)
uistuff.keep(combo, "newgametasker_colorcombo")
widgets['yourColorLabel'].set_mnemonic_widget(combo)
# We need to wait until after engines have been discovered, to init the
# playerCombos. We use connect_after to make sure, that newGameDialog
# has also had time to init the constants we share with them.
self.playerCombo = Gtk.ComboBox()
widgets["opponentDock"].add(self.playerCombo)
discoverer.connect_after("all_engines_discovered",
self.__initPlayerCombo, widgets)
widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo)
def on_skill_changed(scale):
# Just to make sphinx happy...
try:
pix = newGameDialog.skillToIconLarge[int(scale.get_value())]
widgets["skillImage"].set_from_pixbuf(pix)
except TypeError:
pass
widgets["skillSlider"].connect("value-changed", on_skill_changed)
on_skill_changed(widgets["skillSlider"])
widgets["startButton"].connect("clicked", self.startClicked)
self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:42,代码来源:TaskerManager.py
示例7: run
def run(widgets):
global firstRun, engine_dialog
if firstRun:
# Display of the countries
items = []
for iso in ISO3166_LIST:
path = addDataPrefix("flags/%s.png" % iso.iso2)
if not(iso.iso2 and os.path.isfile(path)):
path = addDataPrefix("flags/unknown.png")
items.append((get_pixbuf(path), iso.country))
uistuff.createCombo(widgets["engine_country_combo"], name="engine_country_combo",
ellipsize_mode=Pango.EllipsizeMode.END)
data = [(item[0], item[1]) for item in items]
uistuff.updateCombo(widgets["engine_country_combo"], data)
engine_dialog = EnginesDialog(widgets)
def cancel_event(widget, with_confirmation, *args):
# Confirm if the changes need to be saved
modified = discoverer.hasChanged()
if modified and with_confirmation:
dialog = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
dialog.set_markup(_("You have unsaved changes. Do you want to save before leaving?"))
response = dialog.run()
dialog.destroy()
# if response == Gtk.ResponseType.CANCEL:
# return False
if response == Gtk.ResponseType.NO:
discoverer.restore()
if response == Gtk.ResponseType.YES:
discoverer.save()
# Close the window
widgets["manage_engines_dialog"].hide()
return True
def save_event(widget, *args):
discoverer.save()
widgets["manage_engines_dialog"].hide()
return True
widgets["manage_engines_dialog"].connect("delete-event", cancel_event, True)
widgets["engine_cancel_button"].connect("clicked", cancel_event, False)
widgets["engine_save_button"].connect("clicked", save_event)
widgets["manage_engines_dialog"].connect(
"key-press-event",
lambda w, e: cancel_event(w, True) if e.keyval == Gdk.KEY_Escape else None)
discoverer.backup()
engine_dialog.widgets["enginebook"].set_current_page(0)
widgets["manage_engines_dialog"].show()
if not firstRun:
engine_dialog.update_store()
firstRun = False
开发者ID:leogregianin,项目名称:pychess,代码行数:54,代码来源:enginesDialog.py
示例8: __init__
def __init__ (self, widgets):
self.themes = self.discover_themes()
store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
for theme in self.themes:
pngfile = "%s/%s.png" % (addDataPrefix("pieces"), theme)
if isfile(pngfile):
pixbuf = get_pixbuf(pngfile)
store.append((pixbuf, theme))
else:
print("WARNING: No piece theme preview icons found. Please run create_theme_preview.sh !")
break
iconView = widgets["pieceTheme"]
iconView.set_model(store)
iconView.set_pixbuf_column(0)
iconView.set_text_column(1)
#############################################
# Hack to fix spacing problem in iconview
# http://stackoverflow.com/questions/14090094/what-causes-the-different-display-behaviour-for-a-gtkiconview-between-different
def keep_size(crt, *args):
crt.handler_block(crt_notify)
crt.set_property('width', 40)
crt.handler_unblock(crt_notify)
crt, crp = iconView.get_cells()
crt_notify = crt.connect('notify', keep_size)
#############################################
def _get_active(iconview):
model = iconview.get_model()
selected = iconview.get_selected_items()
if len(selected) == 0:
return conf.get("pieceTheme", "Chessicons")
indices = selected[0].get_indices()
if indices:
i = indices[0]
theme = model[i][1]
Pieces.set_piece_theme(theme)
return theme
def _set_active(iconview, value):
try:
index = self.themes.index(value)
except ValueError:
index = 0
iconview.select_path(Gtk.TreePath(index,))
uistuff.keep(widgets["pieceTheme"], "pieceTheme", _get_active,
_set_active, "Chessicons")
开发者ID:ZeepXanflorp,项目名称:pychess,代码行数:54,代码来源:preferencesDialog.py
示例9: __init__
def __init__(self, widgets):
# Put panels in trees
self.widgets = widgets
persp = perspective_manager.get_perspective("games")
sidePanels = persp.sidePanels
dockLocation = persp.dockLocation
saved_panels = []
xmlOK = os.path.isfile(dockLocation)
if xmlOK:
doc = minidom.parse(dockLocation)
for elem in doc.getElementsByTagName("panel"):
saved_panels.append(elem.getAttribute("id"))
store = Gtk.ListStore(bool, GdkPixbuf.Pixbuf, str, object)
for panel in sidePanels:
checked = True if not xmlOK else panel.__name__ in saved_panels
panel_icon = get_pixbuf(panel.__icon__, 32)
text = "<b>%s</b>\n%s" % (panel.__title__, panel.__desc__)
store.append((checked, panel_icon, text, panel))
self.tv = widgets["panels_treeview"]
self.tv.set_model(store)
self.widgets['panel_about_button'].connect('clicked', self.panel_about)
self.widgets['panel_enable_button'].connect('toggled',
self.panel_toggled)
self.tv.get_selection().connect('changed', self.selection_changed)
pixbuf = Gtk.CellRendererPixbuf()
pixbuf.props.yalign = 0
pixbuf.props.ypad = 3
pixbuf.props.xpad = 3
self.tv.append_column(Gtk.TreeViewColumn("Icon",
pixbuf,
pixbuf=1,
sensitive=0))
uistuff.appendAutowrapColumn(self.tv, "Name", markup=2, sensitive=0)
widgets['preferences_notebook'].connect("switch-page", self.__on_switch_page)
widgets["preferences_dialog"].connect("show", self.__on_show_window)
widgets["preferences_dialog"].connect("hide", self.__on_hide_window)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:43,代码来源:preferencesDialog.py
示例10: cb
def cb(widget, x, y, keyboard_mode, tooltip, title, desc, filename):
table = Gtk.Table(2, 2)
table.set_row_spacings(2)
table.set_col_spacings(6)
table.set_border_width(4)
pixbuf = get_pixbuf(filename, 56)
image = Gtk.Image.new_from_pixbuf(pixbuf)
image.set_alignment(0, 0)
table.attach(image, 0, 1, 0, 2)
titleLabel = Gtk.Label()
titleLabel.set_markup("<b>%s</b>" % title)
titleLabel.set_alignment(0, 0)
table.attach(titleLabel, 1, 2, 0, 1)
descLabel = Gtk.Label(label=desc)
descLabel.props.wrap = True
table.attach(descLabel, 1, 2, 1, 2)
tooltip.set_custom(table)
table.show_all()
return True
开发者ID:CarbonFixer,项目名称:pychess,代码行数:19,代码来源:gamewidget.py
示例11: country_changed
def country_changed(widget):
if self.cur_engine is not None and not self.selection:
engine = discoverer.getEngineByName(self.cur_engine)
old_country = discoverer.getCountry(engine)
new_country = ISO3166_LIST[widget.get_active()].iso2
if old_country != new_country:
engine["country"] = new_country
# Refresh the flag in the tree view
path = addDataPrefix("flags/%s.png" % new_country)
if not os.path.isfile(path):
path = addDataPrefix("flags/unknown.png")
item = self.tv.get_selection().get_selected()
if item is not None:
model, ts_iter = item
model[ts_iter][0] = get_pixbuf(path)
# Notify playerCombos in NewGameTasker
discoverer.emit("all_engines_discovered")
开发者ID:leogregianin,项目名称:pychess,代码行数:19,代码来源:enginesDialog.py
示例12: run
def run(widgets):
global firstRun
if firstRun:
# Bubble sort for the translated countries
for i in range(len(ISO3166_LIST) - 1, 1, - 1):
for j in range(1, i - 1):
if ISO3166_LIST[i].country < ISO3166_LIST[j].country:
tmp = ISO3166_LIST[i]
ISO3166_LIST[i] = ISO3166_LIST[j]
ISO3166_LIST[j] = tmp
# Display of the countries
items = []
for iso in ISO3166_LIST:
path = addDataPrefix("flags/%s.png" % iso.iso2)
if not(iso.iso2 and os.path.isfile(path)):
path = addDataPrefix("flags/unknown.png")
items.append((get_pixbuf(path), iso.country))
uistuff.createCombo(widgets["engine_country_combo"], name="engine_country_combo",
ellipsize_mode=Pango.EllipsizeMode.END)
data = [(item[0], item[1]) for item in items]
uistuff.updateCombo(widgets["engine_country_combo"], data)
EnginesDialog(widgets)
def delete_event(widget, *args):
widgets["manage_engines_dialog"].hide()
return True
widgets["manage_engines_dialog"].connect("delete-event", delete_event)
widgets["engines_close_button"].connect("clicked", delete_event)
widgets["manage_engines_dialog"].connect(
"key-press-event",
lambda w, e: delete_event(w) if e.keyval == Gdk.KEY_Escape else None)
firstRun = False
widgets["manage_engines_dialog"].show()
开发者ID:teacoffee2017,项目名称:pychess,代码行数:37,代码来源:enginesDialog.py
示例13: __on_show_window
def __on_show_window(self, widget):
notebook = self.widgets['preferences_notebook']
page_num = notebook.get_current_page()
if notebook.get_nth_page(page_num) == self.widgets['sidepanels']:
self.showit()
def __on_hide_window(self, widget):
self.hideit()
# Theme initing
board_items = [(None, "colors only")]
boards_path = addDataPrefix("boards")
board_items += [(get_pixbuf(os.path.join(boards_path, b), 24), b[:-6]) for b in listdir(boards_path) if b.endswith("_d.png")]
class ThemeTab:
""" :Description: Allows the setting of various user specific chess
sets and board colours
"""
def __init__(self, widgets):
self.widgets = widgets
# Font chooser
font = conf.get("movetextFont", "FreeSerif Regular 12")
font_button = Gtk.FontButton.new_with_font(font)
demo_text = "♔a1 ♕f8 ♖h8 ♗g7 ♘g2 Ka1 Qf8 Rh8 Bg7 Ng2"
font_button.set_preview_text(demo_text)
self.widgets["fontChooserDock"].add(font_button)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:30,代码来源:preferencesDialog.py
示例14: _init
def _init(cls):
cls.white = get_pixbuf("glade/white.png")
cls.black = get_pixbuf("glade/black.png")
cls.widgets = uistuff.GladeWidgets("newInOut.glade")
cls.widgets["newgamedialog"].set_transient_for(mainwindow())
def on_exchange_players(widget, button_event):
white = cls.widgets["whitePlayerCombobox"].get_active()
black = cls.widgets["blackPlayerCombobox"].get_active()
whiteLevel = cls.widgets["skillSlider1"].get_value()
blackLevel = cls.widgets["skillSlider2"].get_value()
cls.widgets["whitePlayerCombobox"].set_active(black)
cls.widgets["blackPlayerCombobox"].set_active(white)
cls.widgets["skillSlider1"].set_value(blackLevel)
cls.widgets["skillSlider2"].set_value(whiteLevel)
cls.widgets["whitePlayerButton"].set_image(Gtk.Image.new_from_pixbuf(cls.white))
cls.widgets["whitePlayerButton"].connect("button-press-event", on_exchange_players)
cls.widgets["blackPlayerButton"].set_image(Gtk.Image.new_from_pixbuf(cls.black))
cls.widgets["blackPlayerButton"].connect("button-press-event", on_exchange_players)
uistuff.createCombo(cls.widgets["whitePlayerCombobox"], name="whitePlayerCombobox")
uistuff.createCombo(cls.widgets["blackPlayerCombobox"], name="blackPlayerCombobox")
cls.widgets["playersIcon"].set_from_pixbuf(big_people)
cls.widgets["timeIcon"].set_from_pixbuf(big_time)
def on_playerCombobox_changed(widget, skill_hbox, skill_level):
position = widget.get_active()
skill_hbox.props.visible = position > 0
if position > 0:
tree_iter = widget.get_active_iter()
if tree_iter is not None:
engine_name = widget.get_model()[tree_iter][1]
engine = discoverer.getEngineByName(engine_name)
if engine:
pref_level = engine.get("level")
if pref_level:
skill_level.set_value(pref_level)
cls.widgets["whitePlayerCombobox"].connect("changed", on_playerCombobox_changed, cls.widgets["skillHbox1"], cls.widgets["skillSlider1"])
cls.widgets["blackPlayerCombobox"].connect("changed", on_playerCombobox_changed, cls.widgets["skillHbox2"], cls.widgets["skillSlider2"])
cls.widgets["whitePlayerCombobox"].set_active(0)
cls.widgets["blackPlayerCombobox"].set_active(1)
def on_skill_changed(scale, image):
image.set_from_pixbuf(skillToIcon[int(scale.get_value())])
cls.widgets["skillSlider1"].connect("value-changed", on_skill_changed, cls.widgets["skillIcon1"])
cls.widgets["skillSlider2"].connect("value-changed", on_skill_changed, cls.widgets["skillIcon2"])
cls.widgets["skillSlider1"].set_value(3)
cls.widgets["skillSlider2"].set_value(3)
cls.__initTimeRadio("ngblitz", cls.widgets["blitzRadio"], cls.widgets["configImageBlitz"], 5, 0, 0)
cls.__initTimeRadio("ngrapid", cls.widgets["rapidRadio"], cls.widgets["configImageRapid"], 15, 5, 0)
cls.__initTimeRadio("ngnormal", cls.widgets["normalRadio"], cls.widgets["configImageNormal"], 45, 15, 0)
cls.__initTimeRadio("ngclassical", cls.widgets["classicalRadio"], cls.widgets["configImageClassical"], 3, 0, 40)
cls.__initVariantRadio("ngvariant1", cls.widgets["playVariant1Radio"], cls.widgets["configImageVariant1"])
cls.__initVariantRadio("ngvariant2", cls.widgets["playVariant2Radio"], cls.widgets["configImageVariant2"])
def updateCombos(*args):
if cls.widgets["playNormalRadio"].get_active():
variant = NORMALCHESS
elif cls.widgets["playVariant1Radio"].get_active():
variant = conf.get("ngvariant1")
else:
variant = conf.get("ngvariant2")
variant1 = conf.get("ngvariant1")
cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
variant2 = conf.get("ngvariant2")
cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
data = [(item[0], item[1]) for item in playerItems[variant]]
uistuff.updateCombo(cls.widgets["blackPlayerCombobox"], data)
uistuff.updateCombo(cls.widgets["whitePlayerCombobox"], data)
discoverer.connect_after("all_engines_discovered", updateCombos)
updateCombos(discoverer)
conf.notify_add("ngvariant1", updateCombos)
conf.notify_add("ngvariant2", updateCombos)
cls.widgets["playNormalRadio"].connect("toggled", updateCombos)
cls.widgets["playNormalRadio"].set_tooltip_text(variants[NORMALCHESS].__desc__)
cls.widgets["playVariant1Radio"].connect("toggled", updateCombos)
variant1 = conf.get("ngvariant1")
cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
cls.widgets["playVariant2Radio"].connect("toggled", updateCombos)
variant2 = conf.get("ngvariant2")
cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
# The "variant" has to come before players, because the engine positions
# in the user comboboxes can be different in different variants
for key in ("whitePlayerCombobox", "blackPlayerCombobox",
"skillSlider1", "skillSlider2", "notimeRadio",
"blitzRadio", "rapidRadio", "normalRadio", "classicalRadio",
"playNormalRadio", "playVariant1Radio", "playVariant2Radio"):
uistuff.keep(cls.widgets[key], key)
# We don't want the dialog to deallocate when closed. Rather we hide
#.........这里部分代码省略.........
开发者ID:leogregianin,项目名称:pychess,代码行数:101,代码来源:newGameDialog.py
示例15: load
def load(self, widgets, connection, lounge):
self.widgets = widgets
self.connection = connection
self.lounge = lounge
__widget__ = lounge.games_list
self.games = {}
self.recpix = load_icon(16, "media-record")
self.clearpix = get_pixbuf("glade/board.png")
self.tv = self.widgets["gametreeview"]
self.store = Gtk.ListStore(FICSGame, GdkPixbuf.Pixbuf, str, int, str,
int, str, str)
self.game_filter = self.store.filter_new()
self.game_filter.set_visible_func(self.game_filter_func)
self.filter_toggles = {}
self.filter_buttons = ("standard_toggle", "blitz_toggle", "lightning_toggle", "variant_toggle")
for widget in self.filter_buttons:
uistuff.keep(self.widgets[widget], widget)
self.widgets[widget].connect("toggled", self.on_filter_button_toggled)
initial = conf.get(widget, True)
self.filter_toggles[widget] = initial
self.widgets[widget].set_active(initial)
self.model = self.game_filter.sort_new_with_model()
self.tv.set_model(self.model)
self.tv.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
self.addColumns(self.tv,
"FICSGame",
"",
_("White"),
_("Rating"),
_("Black"),
_("Rating"),
_("Type"),
_("Rated"),
hide=[0],
pix=[1])
self.tv.get_model().set_sort_func(0, self.pixCompareFunction, 1)
for i in range(1, 7):
self.tv.get_model().set_sort_func(i, self.compareFunction, i)
self.prev_sort_column_id = []
self.model.connect("sort-column-changed", self.on_sort_column_change)
self.tv.set_has_tooltip(True)
self.tv.connect("query-tooltip", self.on_query_tooltip)
self.selection = self.tv.get_selection()
self.selection.connect("changed", self.onSelectionChanged)
self.onSelectionChanged(self.selection)
try:
self.tv.set_search_position_func(self.lowLeftSearchPosFunc, None)
except AttributeError:
# Unknow signal name is raised by gtk < 2.10
pass
def searchCallback(model, column, key, sel_iter, user_data):
if model.get_value(sel_iter, 2).lower().startswith(key) or \
model.get_value(sel_iter, 4).lower().startswith(key):
return False
return True
self.tv.set_search_equal_func(searchCallback, None)
self.connection.games.connect("FICSGameCreated", self.onGameAdd)
self.connection.games.connect("FICSGameEnded", self.onGameRemove)
self.widgets["observeButton"].connect("clicked", self.on_observe)
self.tv.connect("row-activated", self.on_observe)
self.connection.bm.connect("obsGameCreated", self.onGameObserved)
self.connection.bm.connect("obsGameUnobserved", self.onGameUnobserved)
self.tv.connect('button-press-event', self.button_press_event)
self.createLocalMenu((OBSERVE, FOLLOW, SEPARATOR, FINGER, ARCHIVED))
return __widget__
开发者ID:teacoffee2017,项目名称:pychess,代码行数:78,代码来源:GameListPanel.py
示例16: _ensureReadForGameWidgets
def _ensureReadForGameWidgets():
mainvbox = widgets["mainvbox"]
if len(mainvbox.get_children()) == 3:
return
global background
background = widgets["mainvbox"].get_children()[1]
mainvbox.remove(background)
# Initing headbook
align = createAlignment(4, 4, 0, 4)
align.set_property("yscale", 0)
headbook = Gtk.Notebook()
headbook.set_scrollable(True)
align.add(headbook)
mainvbox.pack_start(align, False, True, 0)
show_tabs(not conf.get("hideTabs", False))
# Initing center
centerVBox = Gtk.VBox()
# The dock
global dock, dockAlign
dock = PyDockTop("main")
dockAlign = createAlignment(4, 4, 0, 4)
dockAlign.add(dock)
centerVBox.pack_start(dockAlign, True, True, 0)
dockAlign.show()
dock.show()
for panel in sidePanels:
hbox = Gtk.HBox()
pixbuf = get_pixbuf(panel.__icon__, 16)
icon = Gtk.Image.new_from_pixbuf(pixbuf)
label = Gtk.Label(label=panel.__title__)
label.set_size_request(0, 0)
label.set_alignment(0, 1)
hbox.pack_start(icon, False, False, 0)
hbox.pack_start(label, True, True, 0)
hbox.set_spacing(2)
hbox.show_all()
def cb(widget, x, y, keyboard_mode, tooltip, title, desc, filename):
table = Gtk.Table(2, 2)
table.set_row_spacings(2)
table.set_col_spacings(6)
table.set_border_width(4)
pixbuf = get_pixbuf(filename, 56)
image = Gtk.Image.new_from_pixbuf(pixbuf)
image.set_alignment(0, 0)
table.attach(image, 0, 1, 0, 2)
titleLabel = Gtk.Label()
titleLabel.set_markup("<b>%s</b>" % title)
titleLabel.set_alignment(0, 0)
table.attach(titleLabel, 1, 2, 0, 1)
descLabel = Gtk.Label(label=desc)
descLabel.props.wrap = True
table.attach(descLabel, 1, 2, 1, 2)
tooltip.set_custom(table)
table.show_all()
return True
hbox.props.has_tooltip = True
hbox.connect("query-tooltip", cb, panel.__title__, panel.__desc__,
panel.__icon__)
docks[panel.__name__] = (hbox, notebooks[panel.__name__])
if os.path.isfile(dockLocation):
try:
dock.loadFromXML(dockLocation, docks)
except Exception as e:
stringio = StringIO()
traceback.print_exc(file=stringio)
error = stringio.getvalue()
log.error("Dock loading error: %s\n%s" % (e, error))
msg_dia = Gtk.MessageDialog(widgets["window1"],
type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.CLOSE)
msg_dia.set_markup(_(
"<b><big>PyChess was unable to load your panel settings</big></b>"))
msg_dia.format_secondary_text(_(
"Your panel settings have been reset. If this problem repeats, \
you should report it to the developers"))
msg_dia.run()
msg_dia.hide()
os.remove(dockLocation)
for title, panel in docks.values():
title.unparent()
panel.unparent()
if not os.path.isfile(dockLocation):
leaf = dock.dock(docks["board"][1],
CENTER,
Gtk.Label(label=docks["board"][0]),
"board")
docks["board"][1].show_all()
#.........这里部分代码省略.........
开发者ID:CarbonFixer,项目名称:pychess,代码行数:101,代码来源:gamewidget.py
示例17: get_pixbuf
from pychess.Players.Human import Human
from pychess.widgets import ImageMenu
from pychess.widgets import mainwindow
from pychess.widgets.BoardControl import BoardControl
from pychess.Savers import fen, pgn
from pychess.Savers.ChessFile import LoadingError
from pychess.Variants import variants
from pychess.Variants.normal import NormalBoard
from pychess.perspectives import perspective_manager
from pychess.perspectives.games import enddir
# ===============================================================================
# We init most dialog icons global to make them accessibly to the
# Background.Taskers so they have a similar look.
# ===============================================================================
big_time = get_pixbuf("glade/stock_alarm.svg")
big_people = load_icon(48, "stock_people", "system-users")
iwheels = load_icon(24, "gtk-execute", "system-run")
ipeople = load_icon(24, "stock_people", "system-users")
inotebook = load_icon(24, "stock_notebook", "computer")
weather_icons = ("clear", "clear-night", "few-clouds", "few-clouds-night",
"fog", "overcast", "severe-alert", "showers-scattered",
"showers", "storm")
skillToIcon = {}
# Used by TaskerManager. Put here to help synchronization
skillToIconLarge = {}
for i, icon in enumerate(weather_icons, start=1):
skillToIcon[2 * i - 1] = get_pixbuf("glade/16x16/weather-%s.png" % icon)
skillToIcon[2 * i] = get_pixbuf("glade/16x16/weather-%s.png" % icon)
skillToIconLarge[2 * i - 1] = get_pixbuf("glade/48x48/weather-%s.png" % icon)
开发者ID:leogregianin,项目名称:pychess,代码行数:31,代码来源:newGameDialog.py
示例18: get_pixbuf
from pychess.Players.engineNest import discoverer
from pychess.Players.Human import Human
from pychess.widgets import BoardPreview
from pychess.widgets import ionest
from pychess.widgets import ImageMenu
from pychess.widgets.BoardControl import BoardControl
from pychess.Savers import fen, pgn
from pychess.Savers.ChessFile import LoadingError
from pychess.Variants import variants
from pychess.Variants.normal import NormalBoard
#===============================================================================
# We init most dialog icons global to make them accessibly to the
# Background.Taskers so they have a similar look.
#===============================================================================
big_time = get_pixbuf("glade/stock_alarm.svg")
big_people = load_icon(48, "stock_people", "system-users")
iwheels = load_icon(24, "gtk-execute", "system-run")
ipeople = load_icon(24, "stock_people", "system-users")
inotebook = load_icon(24, "stock_notebook", "computer")
speople = load_icon(16, "stock_people", "system-users")
snotebook = load_icon(16, "stock_notebook", "computer")
weather_icons = ("clear", "clear-night", "few-clouds", "few-clouds-night", "fog", "overcast", "severe-alert", "showers-scattered", "showers", "storm")
skillToIcon = {}
# Used by TaskerManager. Put here to help synchronization
skillToIconLarge = {}
for i, icon in enumerate(weather_icons, start=1):
skillToIcon[2*i-1] = load_icon(16, "weather-%s" % icon)
skillToIcon[2*i] = load_icon(16, "weather-%s" % icon)
skillToIconLarge[2*i-1] = load_icon(48, "weather-%s" % icon)
开发者ID:jcoffee,项目名称:pychess,代码行数:31,代码来源:newGameDialog.py
示例19: __init__
def __init__(self, widgets):
self.widgets = widgets
# Background image
path = conf.get("welcome_image", addDataPrefix("glade/clear.png"))
conf.set("welcome_image", path)
image_chooser_dialog = Gtk.FileChooserDialog(
_("Select background image file"), None, Gtk.FileC
|
请发表评论