Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Created by Jousway
- --Version 1.4-r
- xpmdata = {
- "32 32 15 1 ",
- " c black",
- ". c #121315",
- "X c #25262B",
- "o c #545861",
- "O c #575B65",
- "+ c red",
- "@ c #00FF18",
- "# c #FFC468",
- "$ c #717683",
- "% c #767B89",
- "& c #787D8B",
- "* c #8E94A5",
- "= c #A3AABD",
- "- c #A5ACBF",
- "; c None",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;#######;;;;;;;;;;;;;",
- ";;;;;;;;;;;;# #;;;;;;;;;;;;;",
- ";;;;;;;;;;;;#######;;;;;;;;;;;;;",
- ";;;;;;;;;;;;# #;;;;;;;;;;;;;",
- ";;;;;;;;;;;;#######;;;;;;;;;;;;;",
- ";;;;;;;;;;;;# #;;;;;;;;;;;;;",
- ";;;;;;;;;;;;#######;;;;;;;;;;;;;",
- ";;;;;;;;;--@-------+--;;;;;;;;;;",
- ";;;;;;;;;-------------;;;;;;;;;;",
- ";;;;;;;;;-- --;;;;;;;;;;",
- ";;;;;;;;;-------------;;;;;;;;;;",
- ";;;;;;;;;---*X%=%X*---;;;;;;;;;;",
- ";;;;;;;;;--&$-- --$&--;;;;;;;;;;",
- ";;;;;;;;;--O--- ---O--;;;;;;;;;;",
- ";;;;;;;;;-o---- ----o-;;;;;;;;;;",
- ";;;;;;;;;-.---- ----.-;;;;;;;;;;",
- ";;;;;;;;;-.---- --.-;;;;;;;;;;",
- ";;;;;;;;;-o---------o-;;;;;;;;;;",
- ";;;;;;;;;--O-------O--;;;;;;;;;;",
- ";;;;;;;;;--&$-----$&--;;;;;;;;;;",
- ";;;;;;;;;---*X%=%X*---;;;;;;;;;;",
- ";;;;;;;;;-------------;;;;;;;;;;",
- ";;;;;;;;;-------------;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
- };
- -- Load the wxLua module, does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit
- package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"
- require("wx")
- --users
- username = {}
- userfile = io.open("Name.txt", "r");
- userread = userfile:read("*a")
- userread:gsub("%w+", function(c) table.insert(username,c) end);
- userfile:close();
- --language file
- language = {}
- langfile = io.open("Lang.ini", "r")
- langread = langfile:read("*a")
- langread:gsub("=(.-)\n", function(c) table.insert(language,c) end);
- langfile:close();
- frame = wx.wxFrame( wx.NULL, -- no parent needed for toplevel windows
- wx.wxID_ANY, -- don't need a wxWindow ID
- "wxLua Time Clock", -- caption on the frame
- wx.wxDefaultPosition, -- let system place the frame
- wx.wxSize(0, 0), -- set the size of the frame
- wx.wxDEFAULT_FRAME_STYLE-wx.wxMINIMIZE_BOX-wx.wxMAXIMIZE_BOX ) -- use default frame styles
- bitmap = wx.wxBitmap(xpmdata)
- icon = wx.wxIcon()
- icon:CopyFromBitmap(bitmap)
- frame:SetIcon(icon)
- bitmap:delete()
- icon:delete()
- frame:SetVirtualSize(9999,9999)
- --create tables
- ID = {}
- ID2 = {}
- previousTime = {}
- timeDifference = {}
- button = {}
- button2 = {}
- atime = {}
- attime = {}
- ttime = {}
- btime = {}
- bttime = {}
- --seconds to clock function
- function SecondsToClock(seconds)
- local seconds = tonumber(seconds)
- if seconds <= 0 then
- return "00:00:00";
- else
- hours = string.format("%02.f", math.floor(seconds/3600));
- mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
- secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
- return hours..":"..mins..":"..secs
- end
- end
- if #username > 10 then
- scrollsize = 2 + (#username * 0.70);
- else
- scrollsize = #username;
- end
- --main body
- sizerTop = wx.wxBoxSizer(wx.wxHORIZONTAL)
- scrollwin = wx.wxScrolledWindow(frame, 1337, wx.wxDefaultPosition, wx.wxSize(700, 460))
- scrollwin:SetScrollbars(0, 50, 0, scrollsize, 0, 0, false)
- flexGridSizer = wx.wxFlexGridSizer( 0, 6, 0, 0 )
- flexGridSizer:AddGrowableCol(1, 0)
- fieldname = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[1])
- checkin = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[2])
- checkout = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[3])
- timecheckedin = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[4])
- timeactive = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[5])
- timecheckedout = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[6])
- fieldname:SetEditable(false)
- checkin:SetEditable(false)
- checkout:SetEditable(false)
- timecheckedin:SetEditable(false)
- timeactive:SetEditable(false)
- timecheckedout:SetEditable(false)
- flexGridSizer:Add(fieldname, 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(checkin, 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(checkout, 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(timecheckedin, 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(timeactive, 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(timecheckedout, 1, wx.wxGROW + wx.wxALL, 6)
- for i = 1,#username do
- ID[i] = 100+i
- ID2[i] = 200+i
- timeDifference[i] = language[7]
- bttime[i] = ""
- attime[i] = ""
- name = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, username[i]);
- button[i] = wx.wxButton(scrollwin, ID[i], language[2])
- button2[i] = wx.wxButton(scrollwin, ID2[i], language[3])
- atime[i] = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[8]);
- ttime[i] = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[8]);
- btime[i] = wx.wxTextCtrl(scrollwin, wx.wxID_ANY, language[9]);
- name:SetEditable(false)
- atime[i]:SetEditable(false)
- ttime[i]:SetEditable(false)
- btime[i]:SetEditable(false)
- flexGridSizer:Add(name, 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(button[i], 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(button2[i], 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(atime[i], 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(ttime[i], 1, wx.wxGROW + wx.wxALL, 6)
- flexGridSizer:Add(btime[i], 1, wx.wxGROW + wx.wxALL, 6)
- end
- export = wx.wxButton(scrollwin, 10001, language[10])
- flexGridSizer:Add(export, 1, wx.wxGROW + wx.wxALL, 6)
- --any button press
- frame:Connect(wx.wxID_ANY, wx.wxEVT_COMMAND_BUTTON_CLICKED,
- function(event)
- for i = 1,#username do
- if event:GetId() == ID[i] then
- previousTime[i] = os.time()
- attime[i] = os.date()
- atime[i]:SetValue(tostring(attime[i]))
- ttime[i]:SetValue(tostring(language[5]))
- elseif event:GetId() == ID2[i] then
- if previousTime[i] ~= nil then
- timeDifference[i] = SecondsToClock(os.time() - previousTime[i])
- ttime[i]:SetValue(timeDifference[i])
- bttime[i] = os.date()
- btime[i]:SetValue(tostring(bttime[i]))
- else
- ttime[i]:SetValue(language[2])
- end
- elseif event:GetId() == 10001 then
- Export(timeDifference,attime,bttime)
- end
- end
- end)
- --export
- function Export(timeDifference,attime,bttime)
- ex = [[<?xml version="1.0"?>
- <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
- xmlns:o="urn:schemas-microsoft-com:office:office"
- xmlns:x="urn:schemas-microsoft-com:office:excel"
- xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
- xmlns:html="http://www.w3.org/TR/REC-html40">
- <Worksheet ss:Name="Checker">
- <Table>
- <Column ss:Width="60"/>
- <Column ss:Width="92"/>
- <Column ss:Width="74"/>
- <Column ss:Width="92"/>
- <Column ss:Width="60"/>
- <Row>
- <Cell><Data ss:Type="String">Naam</Data></Cell>
- <Cell><Data ss:Type="String">Tijd In Gechecked</Data></Cell>
- <Cell><Data ss:Type="String">Tijd Actief</Data></Cell>
- <Cell><Data ss:Type="String">Tijd Uit Gechecked</Data></Cell>
- </Row>]]
- for i = 1,#username do
- ex = ex .."\n"..[[ <Row>]].."\n"..
- [[ <Cell><Data ss:Type="String">]]..username[i]..[[</Data></Cell>]].."\n"..
- [[ <Cell><Data ss:Type="String">]]..attime[i]..[[</Data></Cell>]].."\n"..
- [[ <Cell><Data ss:Type="String">]]..timeDifference[i]..[[</Data></Cell>]].."\n"..
- [[ <Cell><Data ss:Type="String">]]..bttime[i]..[[</Data></Cell>]].."\n"..
- [[ </Row>]].."\n"
- end
- ex = ex .."\n"..[[ </Table>
- </Worksheet>
- </Workbook>]]
- filestring = os.date("%Y-%m-%d %H-%M-%S")
- file = io.open("Priklok "..filestring..".xls", "w")
- file:write(ex)
- file:close()
- end
- sizerTop:Add( flexGridSizer, 0, wx.wxGROW+wx.wxALIGN_CENTER+wx.wxALL, 5 )
- --frame:SetAutoLayout(true)
- frame:SetSizer(sizerTop)
- frame:SetMinSize(wx.wxSize(716, 500));
- frame:SetMaxSize(wx.wxSize(716, 500));
- frame:SetSize(wx.wxSize(716, 500))
- --sizerTop:SetSizeHints(scrollwin)
- -- Start the application
- wx.wxGetApp():SetTopWindow(frame)
- frame:Show(true)
- -- Call wx.wxGetApp():MainLoop() last to start the wxWidgets event loop,
- -- otherwise the wxLua program will exit immediately.
- -- Does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit since the
- -- MainLoop is already running or will be started by the C++ program.
- wx.wxGetApp():MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement