java gui与python gui,来自Java的Python GUI

如果您对新想法和学习新事物持开放态度,那就是这样.

对于您希望加入两种语言的特定问题,这不是一个解决方案,这可以替代将所有内容合并到Python中的想法.

#!/usr/bin/python

import pyglet

from time import time, sleep

class Window(pyglet.window.Window):

def __init__(self):

super(Window, self).__init__(vsync = False)

self.alive = 1

self.click = None

self.drag = False

with open('map.png', 'rb') as fh:

self.geodata_image = pyglet.image.load('map.png', file=fh)

self.geo_info = self.geodata_image.width, self.geodata_image.height

def on_draw(self):

self.render()

def on_mouse_press(self, x, y, button, modifiers):

self.click = x,y

def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):

if self.click:

self.drag = True

print 'Drag offset:',(dx,dy)

def on_mouse_release(self, x, y, button, modifiers):

if not self.drag and self.click:

print 'You clicked here', self.click, 'Relese point:',(x,y)

## Do work on corindate

else:

print 'You draged from', self.click, 'to:',(x,y)

## Move or link two points, or w/e you want to do.

self.click = None

self.drag = False

def render(self):

self.clear()

## An alternative to only getting a region if you only want to show a specific part of

## the image:

# subimage = self.geodata_image.get_region(0, 0, self.geo_info[0], self.geo_info[1])

self.geodata_image.blit(0, 0, 0) # x, y, z from the bottom left corner

self.flip()

def on_close(self):

self.alive = 0

def run(self):

while self.alive:

self.render()

## self.dispatch_events() must be in the main loop

## or any loop that you want to "render" something

## Because it is what lets Pyglet continue with the next frame.

event = self.dispatch_events()

sleep(1.0/25) # 25FPS limit

win = Window()

win.run()

所有你需要的是:

作为Javav子模块运行的Python模型

import sys

for line in sys.stdin.readline():

if line == 'plot':

pass # create image here

例如.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值