本文整理汇总了Python中display.Display.resize_方法的典型用法代码示例。如果您正苦于以下问题:Python Display.resize_方法的具体用法?Python Display.resize_怎么用?Python Display.resize_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类display.Display
的用法示例。
在下文中一共展示了Display.resize_方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import resize_ [as 别名]
#.........这里部分代码省略.........
ms.set_speed(speed)
self.__display.speed_lineedit.setText(str(self.__speed))
def movems(self):
"""Move all MS"""
for ms in self.__ms:
ms.random_move(self.__width-1, self.__height-1)
self.refresh()
def start_moving_ms(self):
"""Start movin MS on map"""
self.__move_timer.start()
def __update_moving_ms(self):
"""Update MS movig state according to interface"""
if self.__display.action_play.isChecked():
self.__move_timer.stop()
else:
self.__move_timer.start()
def load_file(self, filename=None):
"""Load an xml file"""
if not filename:
file_filter = "XML files(*.xml);;All files(*)"
fname = QtGui.QFileDialog.getOpenFileName(filter=file_filter)
if not fname:
return
filename = fname
self.__filename = str(filename)
self.__load_file()
def reload_file(self):
"""Reload current xml file"""
self.__load_file()
def __load_file(self):
"""Load current xml file"""
if not self.__filename:
return
log.nb_handover = 0
# reset map
self.__bts = {}
self.__ms = set()
self.__color_index = 0
# load the new map
xmldoc = xml.dom.minidom.parse(self.__filename)
self.resize(int(xmldoc.getElementsByTagName("Map")[0].getAttribute("size").split(",")[0]),
int(xmldoc.getElementsByTagName("Map")[0].getAttribute("size").split(",")[1]))
px = int(xmldoc.getElementsByTagName("Scale")[0].getAttribute("px"))
meters = int(xmldoc.getElementsByTagName("Scale")[0].getAttribute("meters"))
scale = float(meters)/px
for node in xmldoc.getElementsByTagName("Bts"):
self.add(BTS(
int(node.getAttribute("id")),
getInPx(node.getAttribute("location").split(",")[0], px, meters),
getInPx(node.getAttribute("location").split(",")[1], px, meters),
node.getAttribute("network"),
int(node.getAttribute("ho_margin")),
int(node.getAttribute("ms_txpwr_max")),
int(node.getAttribute("bts_txpwr_max")),
int(node.getAttribute("rxlev_min")),
int(node.getAttribute("max_ms_range")),
int(node.getAttribute("l_rxqual_h")),
int(node.getAttribute("l_rxlev_dl_h")),
int(node.getAttribute("l_rxlev_up_h")),
int(node.getAttribute("pe")),
int(node.getAttribute("ge")),
int(node.getAttribute("f")), scale))
for node in xmldoc.getElementsByTagName("Mobile"):
if (node.getAttribute("location") != ""):
msX = getInPx(node.getAttribute("location").split(",")[0], px, meters)
msY = getInPx(node.getAttribute("location").split(",")[1], px, meters)
else: #TODO dynamic size, depending on xml values
msX = random.randint(0, 799)
msY = random.randint(0,599)
self.add(MS(
int(node.getAttribute("id")),
msX, msY,
node.getAttribute("network"),
int(node.getAttribute("p")),
int(node.getAttribute("pe")),
int(node.getAttribute("ge")),
scale))
def resize(self, width, height):
"""Resize map"""
(self.__width, self.__height) = (width, height)
self.__display.resize_(width, height)
self.refresh()