本文整理汇总了Python中view.View类的典型用法代码示例。如果您正苦于以下问题:Python View类的具体用法?Python View怎么用?Python View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, topoWidget):
View.__init__(self, topoWidget, "FlowTracer")
# Buttons
infoBtn = QtGui.QPushButton('What is FlowTracer?')
self.connect(infoBtn, QtCore.SIGNAL('clicked()'), self.showInfo)
traceBtn = QtGui.QPushButton('Trace!')
self.connect(traceBtn, QtCore.SIGNAL('clicked()'), self.trace_flow)
self.buttons.append(infoBtn)
self.buttons.append(traceBtn)
# Signals
self.topologyInterface.flowtracer_received_signal.connect( \
self.got_json_msg )
# Subscribe to messages from backend
msg = {}
msg["_mux"] = "gui"
msg["type"] = "flowtracer"
msg["command"] = "subscribe"
msg["msg_type"] = "highlight"
self.topologyInterface.send( msg )
self.highlighted_path = []
self.querynode = None
开发者ID:09beeihaq,项目名称:pox,代码行数:25,代码来源:flowtracer.py
示例2: saveState
def saveState(self):
'''
Saves the view's settings to configuration.
'''
View.saveState(self)
config.set(self.NAME, self._CONFIG_SECTION_CONSOLE,
"visible", self._widgetConsole.isVisible())
开发者ID:mlyko,项目名称:tadek-ui,代码行数:7,代码来源:resultview.py
示例3: __init__
class Mission:
def __init__(self, description, actions, level):
self.description = description
self.actions = actions
self.level = level
self.view = View()
def start(self, player):
self.player = player
self.view.mission_description(self.description)
decision = self.view.input_mission_decision(self.actions)
passed_mission = self.determine_outcome(decision)
if passed_mission:
battle = Battle(self.player, self.level)
while battle.take_turn():
pass
if battle.lost == False:
return True
return False
#TODO make random decision
def determine_outcome(self, action):
if action not in self.actions:
return None
elif action == self.actions[0]:
return True
else:
return False
开发者ID:hrgunn,项目名称:MLH,代码行数:30,代码来源:controller.py
示例4: Application
class Application(QApplication):
'''
The main application class where the main objects
are set up and connected with each other.
'''
def __init__(self, *args):
QApplication.__init__(self, *args)
# initialize logging
logging.basicConfig(filename='log.txt', level=logging.INFO,
filemode='w',format='%(asctime)s %(message)s')
logging.info("Starting application.")
# initialize user preferences
preferences = Preferences()
# initialize model
market = GoxMarket(preferences)
# initialize view
self.view = View(preferences, market)
self.connect(self, SIGNAL('lastWindowClosed()'), self.__quit)
def __quit(self):
self.view.stop()
开发者ID:genbtc,项目名称:goxgui,代码行数:28,代码来源:application.py
示例5: __init__
def __init__(self, element, composition, timeline):
goocanvas.Group.__init__(self)
View.__init__(self)
Zoomable.__init__(self)
self.element = element
self.comp = composition
self.timeline = timeline
self.bg = goocanvas.Rect(
height=self.__HEIGHT__,
fill_color_rgba=self.__NORMAL__,
line_width=0)
self.content = Preview(self.element)
self.name = goocanvas.Text(
x=10,
text=os.path.basename(unquote(element.factory.name)),
font="Sans 9",
fill_color_rgba=0x000000FF,
alignment=pango.ALIGN_LEFT)
self.start_handle = StartHandle(element, timeline,
height=self.__HEIGHT__)
self.end_handle = EndHandle(element, timeline,
height=self.__HEIGHT__)
for thing in (self.bg, self.content, self.start_handle, self.end_handle, self.name):
self.add_child(thing)
if element:
self.zoomChanged()
self.normal()
开发者ID:emdash,项目名称:gst-editor,代码行数:33,代码来源:timelineobject.py
示例6: __init__
def __init__(self, topoWidget):
View.__init__(self, topoWidget, "Monitoring")
# Monitoring view buttons
infoBtn = QtGui.QPushButton('What is Monitoring?')
self.connect(infoBtn, QtCore.SIGNAL('clicked()'), self.showInfo)
self.buttons.append(infoBtn)
for b in self.buttons:
b.setCheckable(True)
# maps tuples (dpid, port) to utilization
self.stats = {}
self.topologyInterface.monitoring_received_signal.connect( \
self.got_monitoring_msg )
# Subscribe for linkutils
msg = {}
msg["_mux"] = "gui"
msg ["type"] = "monitoring"
msg ["command"] = "subscribe"
msg ["msg_type"] = "linkutils"
self.topologyInterface.send( msg )
开发者ID:09beeihaq,项目名称:pox,代码行数:26,代码来源:monitoring.py
示例7: __init__
def __init__(self, topoWidget):
View.__init__(self, topoWidget, "Elastic Tree")
self.logDisplay = self.topoWidget.parent.logWidget.logDisplay
utilBtn = QtGui.QPushButton('Change Util Bound')
infoBtn = QtGui.QPushButton('What is ElasticTree?')
self.connect(utilBtn, QtCore.SIGNAL('clicked()'),
self.changeUtil)
self.connect(infoBtn, QtCore.SIGNAL('clicked()'), self.showInfo)
# self.connect(powerBtn, QtCore.SIGNAL('clicked()'),
# self.showPowerStats)
# self.buttons.append(powerBtn)
self.buttons.append(utilBtn)
self.buttons.append(infoBtn)
self.utilBound = 0.01
self.slider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
self.slider.setMinimum(0)
self.slider.setMaximum(100)
self.buttons.append(self.slider)
self.sliderValue = 0
self.stats = {} # maps tuples (dpid, port) to utilization
self.powerSliderSignal.connect(self.changeSlider)
self.indicator = QtGui.QLabel()
self.buttons.append(self.indicator)
开发者ID:09beeihaq,项目名称:pox,代码行数:28,代码来源:elastictree.py
示例8: Infrastructure
class Infrastructure():
def __init__(self, resolution, frame_rate):
self.frame_rate = frame_rate
self.event_manager = EventManager()
self.event_manager.register_listener(self)
self.model = Model(self.event_manager)
self.view = View(self.event_manager, resolution)
self.controller = InputController(self.event_manager)
self.main_loop = True
def update_resolution(self, resolution):
self.view.update_window(resolution)
def update_frame_rate(self, frame_rate):
self.frame_rate = frame_rate
def run_main(self):
while self.main_loop:
clock = pygame.time.Clock()
milliseconds = clock.tick(self.frame_rate)
self.event_manager.post(TickEvent(milliseconds))
def get_event_manager(self):
return self.event_manager
def notify(self, event):
if isinstance(event, QuitEvent):
self.main_loop = False
开发者ID:TheSuiteLife,项目名称:Aspirin,代码行数:28,代码来源:infrastructure.py
示例9: __init__
class Controller:
# Constructor
def __init__(self, root):
# Retrieve my model (or create)
self.my_number = Model()
self.my_number.add_callback(self.number_change)
# Create the view
self.view_number = View(root)
# Link View elements to Controller
self.view_number.inc_button.config(command=self.inc_number)
self.view_number.dec_button.config(command=self.dec_number)
self.number_change(self.my_number.get())
# Action to Model from View elements
def inc_number(self):
self.my_number.set(self.my_number.get() + 1)
def dec_number(self):
self.my_number.set(self.my_number.get() - 1)
# Update View from Model
def number_change(self, n):
self.view_number.update_number(n)
开发者ID:johndspence,项目名称:holbertonschool-higher_level_programming,代码行数:26,代码来源:controller.py
示例10: __init__
def __init__(self, app):
View.__init__(self, app)
self.app_window.feedview.listbox.connect('row-activated', self.show_entries)
self.app_window.feedhandler.connect("feed-updated", self.update_entryview)
self.listbox = Gtk.ListBox()
self.add(self.listbox)
开发者ID:nanamii,项目名称:gylfeed,代码行数:7,代码来源:entrylistview.py
示例11: Application
class Application(QApplication):
'''
The main application class where the main objects
are set up and connected with each other.
'''
def __init__(self, *args):
self.logfile = open('log.txt', 'w')
QApplication.__init__(self, *args)
# initialize model (gox)
#goxapi.FORCE_PROTOCOL = 'socketio'
self.config = goxapi.GoxConfig("goxtool.ini")
self.secret = goxapi.Secret(self.config)
self.gox = goxapi.Gox(self.secret, self.config)
self.strategy_object = stoploss.Strategy(self.gox)
# initialize view
self.view = View(self.gox, self.secret, self.logfile)
self.view.log('Starting application.')
# start connection to MtGox
self.gox.start()
self.connect(self, SIGNAL('lastWindowClosed()'), self.__quit)
def __quit(self):
self.gox.stop()
self.logfile.close()
开发者ID:twhyte,项目名称:goxgui,代码行数:33,代码来源:application.py
示例12: tick
def tick(self):
reported = set()
while self.views_changed:
v, buf = self.views_changed.pop()
if not self.joined_workspace:
msg.debug('Not connected. Discarding view change.')
continue
if 'patch' not in G.PERMS:
continue
if 'buf' not in buf:
msg.debug('No data for buf ', buf['id'], ' ', buf['path'], ' yet. Skipping sending patch')
continue
view = View(v, buf)
if view.is_loading():
msg.debug('View for buf ', buf['id'], ' is not ready. Ignoring change event')
continue
if view.native_id in reported:
continue
reported.add(view.native_id)
patch = utils.FlooPatch(view.get_text(), buf)
# Update the current copy of the buffer
buf['buf'] = patch.current
buf['md5'] = patch.md5_after
self.send(patch.to_json())
reported = set()
self._status_timeout += 1
if self._status_timeout > (2000 / G.TICK_TIME):
self.update_status_msg()
开发者ID:cc7768,项目名称:secret-computing-machine,代码行数:30,代码来源:sublime_connection.py
示例13: main
def main():
if password_changed():
config = Configuration()
indexView=View(config.system.actions)
indexView.output()
else:
redirect()
开发者ID:cernvm,项目名称:cernvm-appliance-agent,代码行数:7,代码来源:index.py
示例14: __init__
class Controller:
def __init__(self):
self.view = View()
self.serialize = Serialize()
def menu(self):
while True:
point = self.view.create_menu()
if point == 1:
self._calculate()
elif point == 2:
self.serialize.load()
elif point == 3:
data = self.view.change_serialization_file()
self.serialize.change_config(data[0], data[1])
elif point == 4:
break
def _calculate(self):
gender = self.view.read_gender()
weight = self.view.read_weight()
height = self.view.read_height()
age = self.view.read_age()
pa = self.view.read_pa()
model = Model(gender, weight, height, age, pa)
self.view.get_info(model.get_info())
data = (gender, weight, height, age, pa, model.calculate_calories())
input()
if self.view.is_dump():
self.serialize.dump(data)
开发者ID:LonelyDragon,项目名称:Architecture,代码行数:30,代码来源:controller.py
示例15: view
def view(self, header_names, lines, vertical_header=None, initial_sort=[], decimal_points=3):
sub_views = []
conv_lines = []
# turn lines to html
for line in lines:
conv_line, sub_sub_views = convert_to_html(line)
conv_lines.append(conv_line)
sub_views += sub_sub_views
conv_sort = []
for s in initial_sort:
dir = 0
if s[1] == 'asc':
dir = 0
elif s[1] == 'desc':
dir = 1
else:
raise Exception('Sort must either be asc or desc')
conv_sort.append('[%d,%d]' % (header_names.index(s[0]), dir))
conv_sort = ', '.join(conv_sort)
conv_sort = '[%s]' % conv_sort
data = OrderedDict()
for i in xrange(len(header_names)):
data[header_names[i]] = [l[i] for l in conv_lines]
html = render('table.html', {
'vertical_header' : vertical_header,
'data' : data,
'id' : self._get_unique_id(),
'header_names': header_names,
'lines': conv_lines,
'sort': conv_sort})
v = View(self, html, ['table.css'], ['jquery.tablesorter.js'])
for sub in sub_views:
v.append_view_files(sub)
return v
开发者ID:ericjsolis,项目名称:danapeerlab,代码行数:35,代码来源:table.py
示例16: __init__
def __init__(self, app):
View.__init__(self, app)
self.app_window.entrylist.listbox.connect('row-activated', self.show_entry_details)
self.scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
self.overlay = Gtk.Overlay()
self.web = WebKit.WebView()
self.web.set_size_request(300, 200)
scw = Gtk.ScrolledWindow()
scw.add(self.web)
self.overlay.add(scw)
self.add(self.overlay)
self.headline = ""
self.plot = ""
self.author = ""
self.prev_listbox = None
self.entry_id = None
image = Gtk.Image.new_from_icon_name('edit-redo-symbolic', Gtk.IconSize.BUTTON)
self.browse_button = Gtk.Button(label=" Show Article ", image=image)
self.browse_button.set_valign(Gtk.Align.END)
self.browse_button.set_halign(Gtk.Align.START)
self.browse_button.set_margin_start(20)
self.browse_button.set_margin_bottom(15)
self.browse_button.set_relief(Gtk.ReliefStyle.NONE)
self.browse_button.connect("clicked", self.browse_link)
self.browse_button.set_always_show_image (True)
self.overlay.add_overlay(self.browse_button)
self.overlay.show()
开发者ID:nanamii,项目名称:gylfeed,代码行数:32,代码来源:entrydetailsview.py
示例17: __init__
def __init__(self, topoWidget):
View.__init__(self, topoWidget)
self.name = "Traffic Engineering"
# TE view buttons
TTBtn = QtGui.QPushButton('&Tunnel Table')
TEDBtn = QtGui.QPushButton('Traffic Engineering &Database')
NewTunBtn = QtGui.QPushButton('New Tunnel...')
DelTunBtn = QtGui.QPushButton('Delete Tunnel...')
self.connect(TTBtn, QtCore.SIGNAL('clicked()'), self.handle_TTBtnClick)
self.connect(TEDBtn, QtCore.SIGNAL('clicked()'), self.request_TED)
self.connect(NewTunBtn, QtCore.SIGNAL('clicked()'), self.new_tunnel)
self.connect(DelTunBtn, QtCore.SIGNAL('clicked()'), self.remove_tunnel)
self.buttons.append(TTBtn)
self.buttons.append(TEDBtn)
self.buttons.append(NewTunBtn)
self.buttons.append(DelTunBtn)
self.buttons[0].setCheckable(True)
#self.buttons[2].setCheckable(True)
#self.buttons[3].setCheckable(True)
# tunnel descriptions, taken from te backend
self.tunnels = []
# backup tables, string taken from te backend
self.backup_tables = ""
# unprotected hops per tunnel, string taken from te backend
self.uprotected_hops = ""
# unaccommodated tunnels, string taken from te backend
self.unaccomodated_tunnels = ""
# latest TED, string taken from te backend
self.ted = ""
# tunnel colors (tid:color)
self.tunnel_colors = {'default':QtCore.Qt.blue,\
1:QtGui.QColor(QtCore.Qt.red),\
2:QtGui.QColor(QtCore.Qt.yellow)}
# draw tunnel? (tid:true/false)
self.tunnel_displays = {1:True, 2:True} #{0:False, 1:False}
# connect signals to slots
self.topologyInterface.tunnels_reply_received_signal.connect \
(self.show_tunnel_table)
self.topologyInterface.ted_reply_received_signal.connect \
(self.show_TED)
self.topologyInterface.link_status_change_signal.connect \
(self.update_tunnel_table)
self.popupTT = False
开发者ID:homework,项目名称:hwdb,代码行数:59,代码来源:te.py
示例18: convertDate
def convertDate(self, dictionary):
view = View()
if "day" in dictionary.keys():
dictionary["day"] = view.days_str(dictionary["day"])
if "startTime" in dictionary.keys():
dictionary["startTime"] = view.time_str(dictionary["startTime"])
if "endTime" in dictionary.keys():
dictionary["endTime"] = view.time_str(dictionary["endTime"])
开发者ID:xil12008,项目名称:paxos,代码行数:8,代码来源:consumer.py
示例19: _delayedRender
def _delayedRender(self, request, settings):
try:
properties, per_index = self.properties, self.per_index
if request.path == "/properties/api.json":
items = []
for i in xrange(30):
item = self.model.get_item(i)
items.append({'id': i, "title": "better " + item['title']})
request.setHeader("content-type", "application/json")
request.write(json.dumps(items))
elif request.path.startswith("/properties/index_"):
m = re.search(r'.*_(\d+)', request.path)
if not m:
raise Exception('expected number')
page = int(m.group(1))
# Divide with roundup
indices = (properties + per_index - 1) / per_index
if page >= indices:
raise Exception('invalid index number')
np = "index_%05d.html" % (page+1)
start = per_index * page
end = min(per_index * (page + 1), properties)
index = {
'page': page,
'nextp': None if page >= (indices-1) else np,
'items': self.model.get_items(xrange(start, end))
}
request.write(View.render_index(index))
elif request.path.startswith("/properties/property_"):
m = re.search(r'.*_(\d+)', request.path)
if not m:
raise Exception('expected number')
pid = int(m.group(1))
if pid >= properties:
raise Exception('invalid property number')
item = self.model.get_item(pid)
request.write(View.render_property(item))
else:
raise Exception('unknown page')
except:
request.write('can\'t find page. sorry')
request.finish()
开发者ID:scalingexcellence,项目名称:scrapybook-docker-web,代码行数:58,代码来源:web.py
示例20: main
def main():
'''
generates an error page
'''
config=Configuration()
fs=cgi.FieldStorage()
view = View(config.system.actions)
view.setContent('Page not found', 'The requested page was not found. Did you type the url manually?')
view.output()
开发者ID:Hunterbond,项目名称:pi-web-agent,代码行数:9,代码来源:error_page.py
注:本文中的view.View类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论