graph.DrawLine((0,-SIZE_Y), (0,SIZE_Y))

    for x in range(-SIZE_X, SIZE_X+1, NUMBER_MARKER_FREQUENCY):
        graph.DrawLine((x,-3), (x,3))                       # tick marks
        if x != 0:
            graph.DrawText( str(x), (x,-10), color='green')      # numeric labels

    for y in range(-SIZE_Y, SIZE_Y+1, NUMBER_MARKER_FREQUENCY):
        graph.DrawLine((-3,y), (3,y))
        if y != 0:
            graph.DrawText( str(y), (-10,y), color='blue')

# Create the graph that will be put into the window
graph = sg.Graph(canvas_size=(400, 400),
          graph_bottom_left=(-(SIZE_X+5), -(SIZE_Y+5)),
          graph_top_right=(SIZE_X+5, SIZE_Y+5),
          background_color='white',
          key='graph')
# Window layout
layout = [[sg.Text('Example of Using Math with a Graph', justification='center', size=(50,1), relief=sg.RELIEF_SUNKEN)],
          [graph],
          [sg.Text('y = sin(x / x2 * x1)', font='COURIER 18')],
          [sg.Text('x1'),sg.Slider((0,200), orientation='h', enable_events=True,key='_SLIDER_')],
          [sg.Text('x2'),sg.Slider((1,200), orientation='h', enable_events=True,key='_SLIDER2_')]]

window = sg.Window('Graph of Sine Function', layout)

while True:
    event, values = window.Read()
    if event is None:
        break
Exemple #2
0
        for _ in range(1, 200):
            x = random.randint(0, 600)
            y = random.randint(0, 400)
            r = random.randint(1, 10)
            ball = Ball(x, y, r)
            self.arena_balls.append(ball)
            area.space.add(ball.body, ball.shape)
            ball.gui_circle_figure = graph_elem.draw_circle((x, y),
                                                            r,
                                                            fill_color='black',
                                                            line_color='red')


# -------------------  Build and show the GUI Window -------------------
graph_elem = sg.Graph((600, 400), (0, 400), (600, 0),
                      enable_events=True,
                      key='_GRAPH_',
                      background_color='lightblue')

layout = [[
    sg.Text('Ball Test'),
    sg.Text('My IP {}'.format(socket.gethostbyname(socket.gethostname())))
], [graph_elem], [sg.Button('Kick'), sg.Button('Exit')]]

window = sg.Window('Window Title', layout, finalize=True)
area = Playfield()
area.add_balls()

# ------------------- GUI Event Loop -------------------
while True:  # Event Loop
    event, values = window.read(timeout=0)
    # print(event, values)
Exemple #3
0
# map = loadMap.ModelMap()
#
# xxx = list(map.PointDic.keys())
tcs = webapi.opentcs("127.0.0.1")
vehicles = tcs.get_vehicles_status()
locations = tcs.get_locations()
points = tcs.get_points()
paths = tcs.get_paths()
xxx = [i['name'] for i in locations]
points_pose = [[i['name'],i['position']['x']/200,i['position']['y']/200] for i in points]
points_dic = dict(zip([i[0] for i in points_pose], [i[1:] for i in points_pose]))
path_list = [[i['sourcePoint']['name'], i['destinationPoint']['name']] for i in paths]
# print(path_list)
print(xxx)
# print(points_pose)
graph_elem = sg.Graph((400, 200), (-10, -20), (390, 180),
                      enable_events=True, key='_GRAPH_', background_color='lightblue')
vehicle_graph = None
vehicle_path_graph = None
vehicle_current_order = None

layout = [
    [graph_elem],
    [sg.Text('车辆状态:', size=(10, 1), font=('Comix san ms', 16), text_color='black')],
    [sg.Table(values=v, col_widths=[4, 4, 4, 4, 10], auto_size_columns=0, num_rows=4, display_row_numbers=0, justification='center', text_color='black')],
    [sg.Text('订单状态:', size=(10, 1), font=('Comix san ms', 16), text_color='black')],
    [sg.Table(values=vv, col_widths=[6, 6, 4, 8], auto_size_columns=0, select_mode=sg.TABLE_SELECT_MODE_BROWSE, num_rows=2, display_row_numbers=False, justification='center', text_color='black')],
    [sg.Button('取消订单'), sg.Button('暂停订单'), sg.Button('继续订单')],
    [sg.Text('新建订单:', size=(10, 1), font=('Comix san ms', 16), text_color='black')],
    [sg.Text('目标点', size=(6,1)), sg.Combo(xxx, size=(6, 1), auto_size_text=False, enable_events=True, key='Target'), sg.Text('动作: '), sg.Combo(['无', '载货', '卸货', '充电'], size=(7, 1), enable_events=True, key='action'), sg.Button('添加')],
    [sg.Table(values=vvv, col_widths=[5, 6, 4], auto_size_columns=0, num_rows=4, display_row_numbers=0, justification='center', text_color='black', key='transport')],
    [sg.Button('取消订单',button_color=('red')), sg.Button('下单', button_color=('green'))]