本文整理汇总了Python中display.Display.show方法的典型用法代码示例。如果您正苦于以下问题:Python Display.show方法的具体用法?Python Display.show怎么用?Python Display.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类display.Display
的用法示例。
在下文中一共展示了Display.show方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DisplayTest
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import show [as 别名]
class DisplayTest(unittest.TestCase):
def setUp(self):
filepath = os.path.dirname(os.path.abspath(__file__)) + '/sample/sample0.json'
layout = GreedyLayout(filepath, 800, 600)
self.display = Display(layout)
def testShow(self):
self.display.show()
def testSomeCase(self):
self.case1()
self.case2()
def case1(self):
filepath = os.path.dirname(os.path.abspath(__file__)) + '/sample/sample2.json'
layout = GreedyLayout(filepath, 1500, 1000)
self.display = Display(layout)
self.display.show()
self.score(layout)
def case2(self):
filepath = os.path.dirname(os.path.abspath(__file__)) + '/sample/sample5.json'
layout = GreedyLayout(filepath, 1500, 1000)
self.display = Display(layout)
self.display.show()
self.score(layout)
def score(self,layout):
diff_ratio = 0
min_ratio = 0
diff_scale = 0
for page in layout.page_set:
# print page.rect
r = float(page.rect.width) / page.rect.height
mini = 100
for t in rect_types[page.type]:
if r < t.ratio:
mini = min(mini, t.ratio / r)
else:
mini = min(mini, r / t.ratio)
min_ratio = max(min_ratio, mini * mini - 1)
diff_ratio += mini * mini - 1
print "diff ratio:", diff_ratio, "min:", min_ratio
print "diff scale", diff_scale
示例2: Display
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import show [as 别名]
from display import Display
__author__ = 'Dani'
if __name__ == "__main__":
column1 = [18, 23, 4, 17, 27]
column2 = [26, 19, 13, 6, 5]
ports = [column1, column2]
display = Display(5, 2, ports)
text = input('Text: ')
display.write(text)
display.show()
示例3: __init__
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import show [as 别名]
class Carte:
"""Represent a map containing BTS and MS"""
def __init__(self, width=800, height=600):
(self.__width, self.__height) = (width, height)
self.__display = Display(width, height)
self.__bts = {}
self.__ms = set()
self.__color_index = 0
self.__filename = None
self.__speed = 1.
self.__freqs_color = {}
log.nb_handover = 0
self.__display.action_load.triggered.connect(self.load_file)
self.__display.action_reload.triggered.connect(self.reload_file)
self.__display.action_play.triggered.connect(self.__update_moving_ms)
self.__display.action_incSpeed.triggered.connect(
lambda: self.change_speed(1))
self.__display.action_decSpeed.triggered.connect(
lambda: self.change_speed(-1))
self.__display.speed_lineedit.editingFinished.connect(
lambda: self.set_speed(float(self.__display.speed_lineedit.text())))
self.__move_timer = QtCore.QTimer()
self.__move_timer.timeout.connect(self.movems)
self.set_speed(1)
self.__display.show()
def add(self, elem):
"""Add an element on map"""
# Add a BTS and update all MS
if isinstance(elem, BTS):
if not elem.f in self.__freqs_color:
self.__freqs_color[elem.f] = len(self.__freqs_color) + 1
idx_color = self.__freqs_color[elem.f]
color = get_color(idx_color, elem.network == "GSM")
self.__bts[elem] = QtGui.QColor(*color)
bts_set = set(self.__bts.keys())
for ms in self.__ms:
ms.update_bts_list(bts_set)
# Add a MS and update it with BTS list
elif isinstance(elem, MS):
self.__ms.add(elem)
elem.set_speed(self.__speed)
elem.update_bts_list(set(self.__bts.keys()))
else:
return
self.refresh()
def refresh(self):
"""Refresh map display"""
self.__display.clean()
for (bts, color) in self.__bts.iteritems():
self.__display.draw(bts, color)
for ms in self.__ms:
self.__display.draw(ms, self.__bts[ms.bts])
self.__display.update()
def change_speed(self, offset):
"""Change map speed with offset"""
self.set_speed(self.__speed + offset)
def set_speed(self, speed):
"""Set map speed"""
speed = float(min(5, max(0, speed)))
self.__move_timer.setInterval(800/pow(2, speed-1))
self.__speed = speed
for ms in self.__ms:
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:
#.........这里部分代码省略.........