本文整理汇总了Python中gui.MainWindow类的典型用法代码示例。如果您正苦于以下问题:Python MainWindow类的具体用法?Python MainWindow怎么用?Python MainWindow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MainWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
app = QtGui.QApplication(sys.argv)
app_window = MainWindow(display_width,display_height)
app_window.show()
app.exec_()
示例2: main
def main():
# create the Application
app = QtWidgets.QApplication(sys.argv)
# create the event loop
event_loop = QEventLoop(app)
asyncio.set_event_loop(event_loop)
# Create the Gui
main_window = MainWindow()
# plugins to include different websites (and listeners?)
plugin_manager = PluginManager()
plugin_manager.register_main_window(main_window)
# User Settings
settings_manager = SettingsManager()
settings_manager.register_main_window(main_window)
settings_manager.register_plugin_manager(plugin_manager)
main_window.show()
try:
event_loop.run_forever()
except KeyboardInterrupt:
pass
app.deleteLater()
plugin_manager.terminate_plugins()
event_loop.close()
sys.exit()
示例3: main
def main():
"""
Main function for the program
"""
parser = argparse.ArgumentParser(
description="Loop a video between 2 points in time based on rules in "
"a text file."
)
parser.add_argument('timestamp_filename', metavar='F', nargs='?',
help='the location of the timestamp file')
parser.add_argument('--video_filename', metavar='V',
help='the location of the video file')
args = parser.parse_args()
app = QApplication(sys.argv)
with open("gui/application.qss", "r") as theme_file:
app.setStyleSheet(theme_file.read())
main_window = MainWindow()
if args.timestamp_filename:
timestamp_filename = os.path.abspath(args.timestamp_filename)
main_window.set_timestamp_filename(timestamp_filename)
if args.video_filename:
video_filename = os.path.abspath(args.video_filename)
main_window.set_video_filename(video_filename)
sys.exit(app.exec_())
示例4: main
def main(argv):
check_pyopenssl_version()
options = None
app = QApplication(sys.argv)
ui = MainWindow(options)
ui.setWindowTitle('MitmUI v0.1')
ui.show()
sys.exit(app.exec_())
示例5: main
def main():
app = QApplication(sys.argv)
args = app.arguments()
args = map(str, args)
if platform.system() == 'Windows' and 'python' in args[0]:
args = args[1:]
config = parse_args(args[1:])
if config['verbose'] > 0:
logging.basicConfig(level=logging.DEBUG)
win = MainWindow(config)
win.setFixedSize(600, 400)
win.setWindowTitle('BrytonOffline')
win.setWindowIcon(QIcon(resource_path('img/bryton_logo.jpg')))
win.show()
return app.exec_()
示例6: __init__
def __init__(self, queue):
MainWindow.__init__(self, None)
self.workQueue = queue
# set up address events
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.enableAddrButtons, self.addrList)
self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.disableAddrButtons, self.addrList)
# set up timer to check connection
# and update balance
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.update, self.timer)
self.timer.Start(0)
示例7: main
def main():
"""
Start the program
"""
# Initialize the backend
hardware = Hardware("config/hardware.json")
# Initialize the GUI
app = QtGui.QApplication(sys.argv)
window = MainWindow(hardware)
# Start
window.show()
sys.exit(app.exec_())
示例8: loop
def loop(HOST, PORT, CERT):
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.connect((HOST, PORT))
buffer = []
disconnected = False
# The following code explains how to use the GUI.
w = MainWindow()
# update() returns false when the user quits or presses escape.
while w.update():
if disconnected:
continue
try:
rready, wready, xready = select.select([server], [server], [server])
# ready to receive
if server in rready:
data = server.recv(1024)
if not data:
server.close()
w.writeln("<server disconnected>")
disconnected = True
continue
# print message
w.writeln(data.rstrip())
# ready to send
if server in wready:
if len(buffer) > 0:
server.sendall(buffer.pop())
# error
if server in xready:
server.close()
sys.exit(1)
# if the user entered a line getline() returns a string.
line = w.getline()
if line:
buffer.append(line)
w.writeln("> " + line)
# close server on SIGINT
except (KeyboardInterrupt, SystemExit):
print "\nDisconnecting..."
server.close()
print "Cheers!"
sys.exit(0)
示例9: main
def main(path=None, page=None):
"""Run the normal interface."""
app = QtGui.QApplication(sys.argv)
if path is not None:
config.settings.Main.Package = path
window = MainWindow()
if page is not None:
window.set_page(page)
center_window(window)
window.show()
warn.set_warnings_qt()
exit_code = app.exec_()
prepare_quit(window)
return exit_code
示例10: main
def main(mcast_addr,
sensor_pos, sensor_range, sensor_val,
grid_size, ping_period):
"""
mcast_addr: udp multicast (ip, port) tuple.
sensor_pos: (x,y) sensor position tuple.
sensor_range: range of the sensor ping (radius).
sensor_val: sensor value.
grid_size: length of the of the grid (which is always square).
ping_period: time in seconds between multicast pings.
"""
# -- make the gui --
window = MainWindow()
# -- make the node --
node = Node(mcast_addr, sensor_pos,sensor_range, sensor_val, window)
start_time = time.time()
# -- This is the event loop. --
while window.update():
node.updateSelect()
# Auto ping
if (time.time() - start_time) > ping_period:
node.sendPing()
start_time = time.time()
# Check for new messages
for c in node.readable:
# Receive message from server and write to the window
data = c.recvfrom(1024)
parseData(data, node)
# Check if something was entered in the GUI, parse the input and execute the corresponding command
line = window.getline()
if line:
parseInput(line, node)
# # Prevent busy looping
time.sleep(0.1)
示例11: main
def main(mcast_addr,
sensor_pos, sensor_range, sensor_val,
grid_size, ping_period):
"""
mcast_addr: udp multicast (ip, port) tuple.
sensor_pos: (x,y) sensor position tuple.
sensor_range: range of the sensor ping (radius).
sensor_val: sensor value.
grid_size: length of the of the grid (which is always square).
ping_period: time in seconds between multicast pings.
"""
node = nodeContainer()
# -- make sockets
node.init(mcast_addr)
# -- set node values
node.position = sensor_pos
node.range = sensor_range
node.value = sensor_val
node.pingTime = ping_period
# -- create gui
window = MainWindow()
node.setWindow(window)
# -- Command/message parser
parser = msgParser(node)
# -- Both peer and Mcast connections
conns = node.getConnections()
# -- This is the event loop
while window.update():
inputReady, outputReady, errorReady = \
select.select(conns, [], [], 0.025)
# Is it ping time already
node.autoPing()
# Network message
for s in inputReady:
parser.parseSensorMessage(s)
# Gui message
line = window.getline()
if line:
parser.parseLine(line);
示例12: main
def main():
win = MainWindow()
win.setup()
win.set_size_request(600,500)
win.show_all()
gtk.gdk.threads_init()
gtk.main()
示例13: main
def main():
# create the GUI
app = QtWidgets.QApplication(sys.argv)
# create the event loop
event_loop = QEventLoop(app)
asyncio.set_event_loop(event_loop)
main_window = MainWindow()
# need chat_slot to be able to add to add the chat signal
chat_slot = main_window.central_widget.message_area.chat_slot
settings = get_settings_helper()
# this methods also handles passing in values to websites
plugin_manager = instantiate_plugin_manager(settings)
main_window.set_settings(settings)
chat_list = plugin_manager.get_instances()
# connect the sockets signals to the GUI
for chat in chat_list:
chat.chat_signal.connect(chat_slot)
chat.connected_signal.connect(main_window.status_bar.set_widget_status)
listener_interface = pluginmanager.PluginInterface()
listener_interface.collect_plugins(plugins)
listener_list = listener_interface.get_instances() # flake8: noqa
# main_window.central_widget.message_area.listeners = listener_list
main_window.show()
try:
event_loop.run_forever()
except KeyboardInterrupt:
pass
for chat in chat_list:
if chat.process:
chat.process.terminate()
event_loop.close()
sys.exit()
示例14: main
def main():
# create the Application
app = QtWidgets.QApplication(sys.argv)
# create the event loop
event_loop = QEventLoop(app)
asyncio.set_event_loop(event_loop)
# Create the Gui
main_window = MainWindow()
# plugins to include different websites (and listeners?)
plugin_manager = PluginManager()
plugin_manager.register_main_window(main_window)
# User Settings
settings_manager = SettingsManager()
settings_manager.register_main_window(main_window)
settings_manager.register_plugin_manager(plugin_manager)
# listeners handeled separatly for now
listener_interface = pluginmanager.PluginInterface()
listener_interface.collect_plugins(plugins)
listener_list = listener_interface.get_instances() # flake8: noqa
# main_window.central_widget.message_area.listeners = listener_list
main_window.show()
try:
event_loop.run_forever()
except KeyboardInterrupt:
pass
app.deleteLater()
plugin_manager.terminate_plugins()
event_loop.close()
sys.exit()
示例15: main
def main(mcast_addr,
sensor_pos, sensor_range, sensor_val,
grid_size, ping_period):
"""
mcast_addr: udp multicast (ip, port) tuple.
sensor_pos: (x,y) sensor position tuple.
sensor_range: range of the sensor ping (radius).
sensor_val: sensor value.
grid_size: length of the of the grid (which is always square).
ping_period: time in seconds between multicast pings.
"""
# -- Create the multicast listener socket. --
mcast = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
# Sets the socket address as reusable so you can run multiple instances
# of the program on the same machine at the same time.
mcast.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
# Subscribe the socket to multicast messages from the given address.
mreq = struct.pack('4sl', inet_aton(mcast_addr[0]), INADDR_ANY)
mcast.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
if sys.platform == 'win32': # windows special case
mcast.bind( ('localhost', mcast_addr[1]) )
else: # should work for everything else
mcast.bind(mcast_addr)
# -- Create the peer-to-peer socket. --
peer = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
# Set the socket multicast TTL so it can send multicast messages.
peer.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, 5)
# Bind the socket to a random port.
if sys.platform == 'win32': # windows special case
peer.bind( ('localhost', INADDR_ANY) )
else: # should work for everything else
peer.bind( ('', INADDR_ANY) )
# -- make the gui --
window = MainWindow()
window.writeln( 'my address is %s:%s' % peer.getsockname() )
window.writeln( 'my position is (%s, %s)' % sensor_pos )
window.writeln( 'my sensor value is %s' % sensor_val )
# -- This is the event loop. --
while window.update():
pass