Reputation: 11
I have a problem on updating data that I want to insert to excel. At first, I create the data and it work successfully without error. After I want to insert new data from Kivy, it doesn't work. Error said that the process denied by PC. I had watch tutorial and it seem my problem still unsolved. Here is my code from VSCode:
Window.size = (500, 500)
outWorkbook = xlsxwriter.Workbook("staff.xlsx") outSheet = outWorkbook.add_worksheet()
class Menu(Screen): pass
class Enter(Screen):
input1 = ObjectProperty(None)
input2 = ObjectProperty(None)
input3 = ObjectProperty(None)
input4 = ObjectProperty(None)
input5 = ObjectProperty(None)
input6 = ObjectProperty(None)
def clear(self):
self.ids.inherent_input.text = ''
self.ids.inherent2_input.text = ''
self.ids.inherent3_input.text = ''
self.ids.inherent4_input.text = ''
self.ids.inherent5_input.text = ''
self.ids.inherent6_input.text = ''
def btn(self):
self.L = ()
print("Name: " + self.input1.text,
"Activity/Programme: " + self.input2.text,
"Date: " + self.input3.text,
"Place: " + self.input4.text,
"Time from: " + self.input5.text,
"Time to: " + self.input6.text)
staff = ({"Name": [str(self.input1.text)], "Program/Activity": [str(self.input2.text)], "Place" : [str(self.input3.text)], "Date": [str(self.input4.text)], "Time From" : [str(self.input5.text)], "Time To" : [str(self.input6.text)]})
self.L = pd.DataFrame(staff)
self.input1.text = ''
self.input2.text = ''
self.input3.text = ''
self.input4.text = ''
self.input5.text = ''
self.input6.text = ''
print(self.L)
with pd.ExcelWriter('staff.xlsx') as writer:
self.L.to_excel(writer)
class Info(Screen): pass
class WindowManager(ScreenManager): pass
kv = Builder.load_file('window.kv')
class WindowApp(App): def build(self): return kv
if name == 'main': WindowApp().run()
And here is my kv file:
WindowManager:
Menu:
Enter:
Info:
:
name: "MainMenu"
BoxLayout:
orientation: "vertical"
size: root.width, root.height
padding: 10
spacing: 15
Button:
id: enter
text: "Enter"
on_release: app.root.current = "enter"
Button:
id: info
text: "Information"
on_release: app.root.current = "info"
Button:
id: exit
text: "Exit"
on_press: quit()
: name: "enter"
input1: inherent_input
input2: inherent2_input
input3: inherent3_input
input4: inherent4_input
input5: inherent5_input
input6: inherent6_input
BoxLayout:
orientation: "vertical"
size: root.width, root.height
padding:10
spacing:10
BoxLayout:
spacing: 10
Label:
text: "Name"
font_size: 20
TextInput:
id: inherent_input
multiline: False
BoxLayout:
spacing: 10
Label:
text: "Activity/Programme"
font_size: 20
TextInput:
id: inherent2_input
multiline: False
BoxLayout:
spacing: 10
Label:
text: "Place"
font_size: 20
TextInput:
id: inherent3_input
multiline: False
BoxLayout:
Label:
text: "Date"
font_size: 20
TextInput:
id: inherent4_input
multiline: False
BoxLayout:
padding: 10
spacing: 10
Label:
text: "Time from"
font_size: 20
TextInput:
id: inherent5_input
multiline: False
Label:
text: "to"
font_size: 20
TextInput:
id: inherent6_input
multiline: False
BoxLayout:
padding: 15
spacing: 15
Button:
id: clear
text: "Clear"
font_size: 12
on_press: root.clear()
Button:
id: back
text: "Back to Menu"
font_size: 12
on_release: app.root.current = "MainMenu"
Button:
id: submit
text: "Submit"
font_size: 12
on_press: root.btn()
: name: "info"
BoxLayout:
orientation: 'vertical'
padding: 15
spacing: 15
Label:
id: information
text: "This is just a test, an Alpha version of Prototype"
font_size: 20
bold: True
italic: False
outline_color: (0,0,0)
Button:
id: returnBack
text: "Return"
on_release: app.root.current = "MainMenu"
Any help will be appreciated.
Upvotes: 1
Views: 440
Reputation: 717
The error you're getting can mean multiple things.
Are you trying to open a directory?
If so, don't do it. It will most likely result in the error you mentioned.
Is the file you are trying to opened anywhere else?
You may have to close it, for python to open it. You probably have experienced this before when trying to delete a file in the explorer, that is opened somewhere else. Windows won't let you do this. Check whether the file in question is opened before trying to access it.
Upvotes: 0