document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Script Start ===============================================================================================
  2. from tkinter import *   # Imports TKinter
  3. import os               # imports os
  4. import random           # Imports random
  5.  
  6. class database(object): # Most data are put here
  7.     fg = "#FF99cc"
  8.     bg="#3C3C3C"
  9.     current_file = \'none\'
  10.     dir_folder = \'concoctions\'
  11.     file_type = \'.concoction\'
  12.     cur_dir =  os.getcwd()
  13.     cur_title = \'none\'
  14.  
  15. class VENOM(object):
  16.     def check(self): # Import Confirmation
  17.         ven_version = "0.0.1 Build 4"
  18.         ven_title = "Venom for Code Concoction"
  19.         print ("Successully imported:--------------------------------")
  20.         print ("["+ ven_title + " | " + ven_version +"]")
  21.         print ("-----------------------------------------------------")
  22.         return True
  23.  
  24.     def get_files(self,folder): # Gets files from the directory
  25.         cur_dir = db.cur_dir
  26.         lst_entries = os.listdir(cur_dir + chr(92) + folder + chr(92))
  27.         lst_filtered_entries = []
  28.         for every_entry in lst_entries:
  29.             if every_entry[len(every_entry)-len(db.file_type):] == db.file_type:
  30.                 lst_filtered_entries.append(every_entry)
  31.         sorted(lst_filtered_entries)
  32.         for every_entry in lst_filtered_entries:
  33.             lst_list.insert(END, str(every_entry[:-len(db.file_type)]))
  34.  
  35.        
  36.     def select_file(self,useless_arg): # This is called when a file is selected
  37.         temp_cur = db.cur_title
  38.         current_selection = lst_list.curselection()
  39.         int_cur_selection = int(current_selection[0])
  40.         current_name = lst_list.get(int_cur_selection)
  41.         db.current_file = db.cur_dir  + "\\\\" + dir_folder + "\\\\" + current_name + db.file_type
  42.         db.cur_title = current_name
  43.         venom.open_file()
  44.         if temp_cur != current_name:
  45.             btn_change_title.config (state = NORMAL)
  46.             btn_save.config (state = NORMAL)
  47.             btn_del.config (state = NORMAL)
  48.         #print (db.current_file)
  49.  
  50.     def open_file(self):
  51.         cont = \'\'
  52.         cont = open(str(db.current_file), \'r+\', -1)
  53.         content = cont.read(-1)
  54.         venom.clean_area()
  55.         txt_main.insert(1.0, content)
  56.         ent_title.insert(0, db.cur_title)
  57.         cont.close()
  58.  
  59.     def clean_area(self):
  60.         txt_main.delete(1.0,END)
  61.         ent_title.delete(0, END)
  62.  
  63.     def save_file(self):
  64.         target = open(str(db.current_file), \'w+\', -1)
  65.         content = txt_main.get(1.0,END)
  66.         target.write(content)
  67.         btn_save.config (state = DISABLED)
  68.  
  69.     def save_file_h(self,e):
  70.         target = open(str(db.current_file), \'w+\', -1)
  71.         content = txt_main.get(1.0,END)
  72.         target.write(content)
  73.         btn_save.config (state = DISABLED)
  74.        
  75.     def change_title(self):
  76.         c_title = str(ent_title.get())
  77.         c_file = db.cur_dir  + "\\\\" + dir_folder + "\\\\" + c_title + db.file_type
  78.         target = open(c_file, \'w+\', -1)
  79.         content = txt_main.get(1.0,END)
  80.         target.write(content)
  81.         os.remove(db.current_file)
  82.         lst_list.delete(0, END)
  83.         cur_dir = db.cur_dir
  84.         lst_entries = os.listdir(cur_dir + chr(92) + db.dir_folder + chr(92))
  85.         lst_filtered_entries = []
  86.         for every_entry in lst_entries:
  87.             if every_entry[len(every_entry)-len(db.file_type):] == db.file_type:
  88.                 lst_filtered_entries.append(every_entry)
  89.         sorted(lst_filtered_entries)
  90.         cur_ind = 0
  91.         for every_entry in lst_filtered_entries:
  92.             lst_list.insert(END, str(every_entry[:-len(db.file_type)]))
  93.             if every_entry[:-len(db.file_type)] == c_title:
  94.                 lst_list.select_set(cur_ind)
  95.             cur_ind += 1
  96.         db.current_file = db.cur_dir  + "\\\\" + dir_folder + "\\\\" + c_title + db.file_type
  97.         db.cur_title = c_title
  98.         btn_change_title.config (state = DISABLED)
  99.  
  100.     def new_file(self):
  101.         c_randtitle = "[" + str(random.randint(0,65535)) + "] New Concoction"
  102.         c_file = db.cur_dir  + "\\\\" + dir_folder + "\\\\" + c_randtitle + db.file_type
  103.         #print("File: " + str(c_randtitle))
  104.         #print("Dir: " + str(c_file))
  105.         c_new = open(c_file, \'w+\', -1)
  106.         lst_list.delete(0, END)
  107.         venom.get_files(db.dir_folder)
  108.         lst_list.select_set(0)
  109.  
  110.     def del_file(self):
  111.         venom.clean_area()
  112.         os.remove(db.current_file)
  113.         lst_list.delete(0, END)
  114.         lst_list.select_set(0)
  115.         cur_dir = db.cur_dir
  116.         lst_entries = os.listdir(cur_dir + chr(92) + db.dir_folder + chr(92))
  117.         lst_filtered_entries = []
  118.         for every_entry in lst_entries:
  119.             if every_entry[len(every_entry)-len(db.file_type):] == db.file_type:
  120.                 lst_filtered_entries.append(every_entry)
  121.         sorted(lst_filtered_entries)
  122.         cur_ind = 0
  123.         for every_entry in lst_filtered_entries:
  124.             lst_list.insert(END, str(every_entry[:-len(db.file_type)]))      
  125.             cur_ind += 1
  126.         lst_list.select_set(cur_ind-1)
  127.         venom.select_file(True)
  128.         btn_save.config (state = DISABLED)
  129.         btn_del.config (state = DISABLED)
  130.  
  131.     def cl(self, target):
  132.         from tkinter import _tkinter
  133.         try:
  134.             target.config( bg = db.bg, fg = db.fg, \\
  135.                            font= "Courier")
  136.         except _tkinter.TclError:
  137.             target.config( bg = db.bg )
  138.         try:
  139.             target.config(selectbackground = db.fg)
  140.         except _tkinter.TclError:
  141.             target.config( bg = db.bg )
  142.        
  143.  
  144.     def select_all(seelf,event):
  145.         txt_main.tag_add(SEL, "1.0", END)
  146.         txt_main.mark_set(INSERT, "1.0")
  147.         txt_main.see(INSERT)
  148.         return \'break\'
  149.  
  150.     def comment_search(a,b): # Searched for CommentLines
  151.         lst_src = ["[r]","[g]","[b]","[p]","[y]", "[v]"]
  152.         txt_main.tag_config("[r]", foreground = "#ee4444", font = ("Courier", 12, "bold"))
  153.         txt_main.tag_config("[g]", foreground = "#44ee44", font = ("Courier", 12, "bold"))
  154.         txt_main.tag_config("[b]", foreground = "#4444ee", font = ("Courier", 12, "bold"))
  155.         txt_main.tag_config("[p]", foreground = "#FF80C0", font = ("Courier", 12, "bold"))
  156.         txt_main.tag_config("[y]", foreground = "#eeee44", font = ("Courier", 12, "bold"))
  157.         txt_main.tag_config("[v]", foreground = "#D600FF", font = ("Courier", 12, "bold"))
  158.         from tkinter import _tkinter
  159.         for every_tag in lst_src:
  160.             try:
  161.                 src_length = txt_main.get(1.0, END)
  162.                 src_length = len(src_length)
  163.                 src_iteration = 0
  164.                 while src_iteration < src_length:
  165.                     src_start = src_iteration / 10
  166.                     src_position = txt_main.search(every_tag, src_start, stopindex = END)
  167.                     src_end = src_position
  168.                     str_closing = str(every_tag[:1] + "/" + every_tag[1:])
  169.                     src_end_position = txt_main.search(str_closing, src_end, stopindex = END)
  170.                     src_start = src_position
  171.                     src_end = src_end_position
  172.                     txt_main.tag_add(every_tag , src_start, src_end + "+4c")  
  173.                     src_iteration += 1
  174.             except _tkinter.TclError:
  175.                 False
  176.  
  177. # Attributes ------------------------------------------
  178. db = database()     # Assigns the class database to db
  179. venom = VENOM()     # Assigns the class VENOM to venom
  180. #venom.check()      # Checks if Venom is working
  181. min_width = 800     # wnd_main\'s minimum width  in px
  182. min_height = 600    # wnd_main\'s minimum height in px
  183. dir_folder = db.dir_folder # Current dir folder
  184. #------------------------------------------------------
  185.  
  186. # Main WIndow -----------------------------------------
  187. wnd_main = Tk()
  188. wnd_main.config(width = min_width, height = min_height)
  189. wnd_main.minsize(min_width, min_height)
  190. wnd_main.geometry(\'-0+0\')
  191. wnd_main.wm_title("TCC Code Concoctions [Ver. 0.1 Build 3 (Alpha)]")
  192. #------------------------------------------------------
  193.  
  194. # Frames ----------------------------------------------
  195. frm_left = Frame(wnd_main)
  196. frm_left.pack(side = LEFT, fill = Y , padx = 5, pady = 5)
  197. frm_rightup = Frame(wnd_main)
  198. frm_rightup.pack(fill = X)
  199. frm_rightbottom = Frame(wnd_main)
  200. frm_rightbottom.pack(fill = X, side = BOTTOM)
  201. frm_right = Frame(wnd_main)
  202. frm_right.pack(side = RIGHT, expand = True, fill = BOTH)
  203. #-------------------------------------------------------
  204.  
  205. # =========================== LEFT PANEL ==============================
  206. # Scroll Bar ----------------------------------------------------------
  207. scr_list = Scrollbar (frm_left,orient = VERTICAL)
  208. #scr_list.pack(side = RIGHT,fill = Y)
  209. # Label List ----------------------------------------------------------
  210. lbl_list = Label(frm_left, text = "CONCOCTIONS:")
  211. lbl_list.pack(fill = X, side = TOP)
  212. # File List -----------------------------------------------------------
  213. lst_list = Listbox(frm_left, width = 20, yscrollcommand = scr_list.set\\
  214.                    , selectmode = SINGLE, relief = "flat", \\
  215.                    highlightthickness = 0)
  216. lst_list.pack(expand= True, fill = BOTH, pady = 10)
  217. # =====================================================================
  218.  
  219. # ========================== RIGHT PANEL ==============================
  220. # Title Label ------------------------------------------------------TOP
  221. lbl_title = Label(frm_rightup, text= "Title: ")
  222. lbl_title.pack(side = LEFT)
  223. # "Change" Button -----------------------------------------------------
  224. btn_change_title = Button(frm_rightup, text = "Change", \\
  225.                           command = venom.change_title)
  226. btn_change_title.pack(side = RIGHT , padx = 2 , pady = 5)
  227.  
  228. # Scroll Bar -------------------------------------------------------MID
  229. scr_main = Scrollbar (frm_right, orient = VERTICAL)
  230. #scr_main.pack(side= RIGHT, fill = Y)
  231. # Title ---------------------------------------------------------------
  232. ent_title = Entry(frm_rightup)
  233. ent_title.pack(side = LEFT, expand = True, fill = X)
  234. # TextArea-------------------------------------------------------------
  235. txt_main = Text(frm_right, yscrollcommand = scr_main.set, undo=True, \\
  236.                 insertbackground= "#FF80C0")
  237. txt_main.pack(expand = True, fill = BOTH)
  238. # Button Save ------------------------------------------------------BOT
  239. btn_save = Button(frm_rightbottom, text = "Save Concoction", \\
  240.                   command = venom.save_file)
  241. btn_save.pack(side = LEFT , pady = 5 , padx = 2)
  242. txt_main.bind("<Control-Key-s>", venom.save_file_h)
  243. txt_main.bind("<Control-Key-S>", venom.save_file_h)
  244. # Button New ----------------------------------------------------------
  245. btn_new = Button(frm_rightbottom, text = "Create New",\\
  246.                  command = venom.new_file)
  247. btn_new.pack(side = LEFT , pady = 5 , padx = 2)
  248. # Button Delete -------------------------------------------------------
  249. btn_del = Button(frm_rightbottom, text = "Delete Concoction",\\
  250.                  command = venom.del_file)
  251. btn_del.pack(side = RIGHT , pady = 5 , padx = 2)
  252. # =====================================================================
  253.  
  254. # Colorizing-----------------------------------------------------------
  255. venom.cl(wnd_main)
  256. venom.cl(frm_left)
  257. venom.cl(frm_right)
  258. venom.cl(frm_rightup)
  259. venom.cl(frm_rightbottom)
  260. venom.cl(lbl_title)
  261. venom.cl(lst_list)
  262. venom.cl(btn_change_title)
  263. venom.cl(txt_main)
  264. venom.cl(btn_save)
  265. venom.cl(btn_del)
  266. venom.cl(btn_new)
  267. venom.cl(ent_title)
  268. venom.cl(lbl_list)
  269. #----------------------------------------------------------------------
  270.  
  271. # Opening Message -----------------------------------------------------
  272. inst = open(db.cur_dir + "\\\\inst.dll", \'r+\' , -1)
  273. inst_cont = inst.read(-1)
  274. txt_main.insert(1.0, inst_cont)
  275. venom.comment_search(True)
  276. btn_save.config (state = DISABLED)
  277. btn_change_title.config (state = DISABLED)
  278. btn_del.config (state = DISABLED)
  279. #----------------------------------------------------------------------
  280. txt_main.config(fg = "#c0c0c0", pady = 10, padx = 10)
  281. lst_list.config(selectbackground = db.fg, font=("Courier", 10, "bold"))
  282. wnd_main.state(\'zoomed\')
  283. wnd_main.iconbitmap(\'icn.ico\')
  284. lst_list.bind(\'<<ListboxSelect>>\', venom.select_file)
  285. txt_main.bind("<Control-Key-a>", venom.select_all)
  286. txt_main.bind("<Control-Key-A>", venom.select_all)
  287. txt_main.bind("<Key-space>", venom.comment_search)
  288. lst_list.bind("<Motion>", venom.comment_search)
  289. venom.get_files(dir_folder)
  290. txt_main.config (tabs = "1c")
  291. scr_main.config (command = txt_main.yview)
  292. scr_list.config (command = lst_list.yview) # connects scrollbar to list
  293. """ CODE SLOT 001 """
  294. wnd_main.mainloop() # Main window\'s mainloop
  295.  
  296. # Script End =================================================================================================
  297.  
  298. """ CODE 001 ----------------------------------------------
  299. for each_line in range(1000):
  300.    lst_list.insert(END, "Example Item " + str(each_line))
  301. --------------------------------------------------------"""
  302.  
  303.  
  304. """ SCRIPT DETAILS ::::::::::::::::::::::::::::
  305. Scrypt Type     : Fortressed / Husked
  306. Guiding System  : Weak (Script)
  307. Script Version  : 0.1 Build 4
  308.  
  309. Changelog :
  310. [Build 1]   -Foundations Created
  311. [Build 2]   -Main Skin Pack Creation
  312.            -bug fixes
  313. [Build 3]   -added color to selected list and text (db.bg)
  314.            -added #Comment color support \'00ee00\'
  315.            -txt_main foreground changed to \'c0c0c0\'
  316.            -Added save_file_h (binding conflicts)
  317.            -Padding of txt_main changed to 5
  318. [Build 4]   -Removed # as a color code.
  319.            - Added new color codes:
  320.            [r] this is a red line [/r]
  321.            [g] this is a green line [/g]
  322.            [b] this si a blue line [/b]
  323.            [y] this is a yellow line [/y]
  324.            [p] this is a pink line [/p]
  325.            [v] this is a vilot line [/v]
  326.  
  327.  
  328. Bugs :
  329. + When [] is removed formatting will not change.
  330. ::::::::::::::::::::::::::::::::::::::::::::"""
');