本文整理汇总了Python中gui.Gui.append_screenshot方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.append_screenshot方法的具体用法?Python Gui.append_screenshot怎么用?Python Gui.append_screenshot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.Gui
的用法示例。
在下文中一共展示了Gui.append_screenshot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import append_screenshot [as 别名]
#.........这里部分代码省略.........
def check_plugins_cfg_dir(self):
# Each time the program is ran, we must check if for every plugin in src/plugins,
# there's a matching folder in ~/.config/crunchbox/config/. So if the user made a new
# plugin, say, src/plugins/irssi.py, crunchbox will make ~/.config/crunchbox/configs/Irssi,
# where irssi's config file(s) will be saved. This is so it takes minimal effort to add support
# for a new program. Just create <program>.py file and drop it in the plugins folder. Crunchbox
# will take care of the rest.
'''
for filename in plugins.public:
if os.path.exists(self.cb_cfg_dir + '/%s' % filename) == False:
# Put inside try, in case it already exists.
print filename
os.mkdir(self.cb_cfg_dir + '/%s' % filename)
'''
for obj in self.plugin_objects:
if os.path.exists(obj.plugin_cfg_dir) == False:
os.mkdir(obj.plugin_cfg_dir)
# load plugins
def load_plugins(self):
# plugins.public is a list of filenames inside /plugins. (conky.py, bash.py, etc)
# From those values, we can get the class name that belongs to each file. conky.py
# would give us 'Conky'. To get the class name from each file, head over to the link:
# stackoverflow.com/questions/452969/does-python-have-an-equivalent-to-java-class-forname
# We instantiate an object from each class and store it in self.plugins_object. So then
# When we want to save/load everything, just cycle the list calling .save() or .load()
# on each object!
for f in getattr(plugins, 'public'):
m = getattr(plugins, f[:-3])
module = getattr(m, f[:-3].capitalize())
obj = module(self.io) # ie, obj = plugins.conky.Conky(self.io)
self.plugin_objects.append(obj)
# Save and about buttons
def save_clicked(self, w, e):
dialog = SaveDialog(self)
def about_clicked(self, w, e):
dialog = AboutDialog(self)
def save_profile(self, profile_name):
for o in self.plugin_objects:
print 'plugin: ', o
# remember, p is something like plugins.conky.Conky
o.save(profile_name, o) # ie, Conky.save('dark scheme', <conky instance>)
print
print
# Configs have been saved. Take a screenshot
self.save_screenshot(profile_name)
def load_profile(self, w, e):
'''this is called from gui.py when screenshot is clicked'''
# img_name is the name of the screenshot, aka name of our profile
name = w.get_data('img_name')
for o in self.plugin_objects:
o.load(name, o)
# Save screenshot to disk.
# Thanks to toothr, bob2, dash and lalaland1125 on freenode's #python for this :)
def check_screenshot(self, cmd, name):
if call(args=cmd, shell=True) == 0:
self.gui.append_screenshot(name)
self.gui.window.show_all()
return False
else:
self.check_screenshot(cmd)
def save_screenshot(self, name):
'''
unfortunatelly, imagick's screenshots won't show composite windows
transparency like conky or transparent terminals. so we use scrot
when i figure out how to do it, then we only need to call() once with
import -window root -resize 200x175\! %s/%s.jpg;\
convert is part of imagemagick. so user needs that installed. along with scrot"
'''
# When we take a screenshot of the desktop, we hide the crunchbang window.
self.gui.window.hide_all()
path = expanduser('~/.config/crunchbox/screenshots')
# TODO make it so we don't have to use shell=True
scrot = """scrot '%s.jpg' -e "mv '%s.jpg' '%s/%s.jpg'";""" % (name, name, path, name)
convert = """convert -resize 200x125\! '%s/%s.jpg' '%s/%s.jpg'""" % (path, name, path, name)
command = scrot + convert
gobject.timeout_add(390,self.check_screenshot, command, name)
print "The disappearing and reappearing of the program that you just saw is normal."
print "It's so that the Crunchbox window isn't included in the screenshot."
self.gui.window.realize()