我试图用kivy制作一个应用程序,但是我的许可被拒绝了。我在kivy网站上按照xubuntu推荐的方式安装它,添加了ppa并使用sudo apt get。当我运行这个应用程序时,GUI会出现,但是当我按下一个应该返回一些文本的按钮时,GUI关闭了,我得到一个错误消息,我的类“MITMs1”没有属性“self”。我也在使用scapy,我使用python2.7。在
这里有一个类似的问题https://i11.at/dwl/eos/kivy30.pdf,但我的操作系统错误是
OSError: [Errno 13] Permission denied: '/dev/input/event5'
我的全部输出是
^{pr2}$我的代码是
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.lang import Builder
from kivy.app import App
from scapy.all import *
from kivy.uix.scrollview import ScrollView
from kivy.uix.screenmanager import ScreenManager, Screen
from subprocess import check_output
Builder.load_string('''
<MITMs1>:
BoxLayout:
BoxLayout:
orientation: 'vertical'
id: client_box
size_hint: 0.5, 1
spacing: 10
Label:
id: device_lbl
markup: True
size_hint: 1, 1
text: 'LABEL! :)'
TextInput:
id: iface_name
size_hint: 1, .2
text: 'eth0'
multiline: False
BoxLayout:
Button:
size_hint: 1, .2
text: 'Run Ifconfig'
on_release: root.run_ifconfig()
ScrollView:
size_hint: 0.5, 1
do_scroll_x: False
BoxLayout:
orientation: 'vertical'
id: nodes
size_hint: 1, None
''')
class MITMs1(Screen):
def __init__(self, **kwargs):
super(MITMs1, self).__init__(**kwargs)
self.iface_name = self.ids['iface_name']
self.device_lbl = self.ids['device_lbl']
self.client_box = self.ids['client_box']
self.nodes = self.ids['nodes']
def run_ifconfig(self):
self.ifconfig = subprocess.check_output(['ifconfig', self.iface_name.text])
self.iface, self.my_ip, self.MAC, self.Bcast, self.Nmask, self.ipv6 = (self.ifconfig.split()[i] for i in (0, 6, 4, 7, 8, 11))
self.device_lbl.text = ('[color=00ff00][i][b]My Device[/b][/i][/color]' + '\n\n' + 'Interface: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.iface) + '\n\n' + 'IP: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.my_ip[5:]) + '\n\n' + 'MAC: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.self.MAC) + '\n\n' + 'Bcast: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.Bcast[6:]) + '\n\n' + 'Nmask: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.Nmask[5:]) + '\n\n' + 'IP: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.ipv6) + '\n\n'
)
class MITMtool(App):
def build(self):
return sm
sm = ScreenManager()
sm.add_widget(MITMs1(name='MITMs1'))
if __name__=='__main__':
MITMtool().run()
在字符串构造的中间有
format(self.self.MAC)
。这就是为什么您会得到关于没有self.self
的错误。在输入错误并不重要,它只是来自kivy查询你的输入设备,看看有什么可用的。在
相关问题 更多 >
编程相关推荐