# Script Start ===============================================================================================
from tkinter import * # Imports TKinter
import os # imports os
import random # Imports random
class database(object): # Most data are put here
fg = "#FF99cc"
bg="#3C3C3C"
current_file = \'none\'
dir_folder = \'concoctions\'
file_type = \'.concoction\'
cur_dir = os.getcwd()
cur_title = \'none\'
class VENOM(object):
def check(self): # Import Confirmation
ven_version = "0.0.1 Build 4"
ven_title = "Venom for Code Concoction"
print ("Successully imported:--------------------------------")
print ("["+ ven_title + " | " + ven_version +"]")
print ("-----------------------------------------------------")
return True
def get_files(self,folder): # Gets files from the directory
cur_dir = db.cur_dir
lst_entries = os.listdir(cur_dir + chr(92) + folder + chr(92))
lst_filtered_entries = []
for every_entry in lst_entries:
if every_entry[len(every_entry)-len(db.file_type):] == db.file_type:
lst_filtered_entries.append(every_entry)
sorted(lst_filtered_entries)
for every_entry in lst_filtered_entries:
lst_list.insert(END, str(every_entry[:-len(db.file_type)]))
def select_file(self,useless_arg): # This is called when a file is selected
temp_cur = db.cur_title
current_selection = lst_list.curselection()
int_cur_selection = int(current_selection[0])
current_name = lst_list.get(int_cur_selection)
db.current_file = db.cur_dir + "\\\\" + dir_folder + "\\\\" + current_name + db.file_type
db.cur_title = current_name
venom.open_file()
if temp_cur != current_name:
btn_change_title.config (state = NORMAL)
btn_save.config (state = NORMAL)
btn_del.config (state = NORMAL)
#print (db.current_file)
def open_file(self):
cont = \'\'
cont = open(str(db.current_file), \'r+\', -1)
content = cont.read(-1)
venom.clean_area()
txt_main.insert(1.0, content)
ent_title.insert(0, db.cur_title)
cont.close()
def clean_area(self):
txt_main.delete(1.0,END)
ent_title.delete(0, END)
def save_file(self):
target = open(str(db.current_file), \'w+\', -1)
content = txt_main.get(1.0,END)
target.write(content)
btn_save.config (state = DISABLED)
def save_file_h(self,e):
target = open(str(db.current_file), \'w+\', -1)
content = txt_main.get(1.0,END)
target.write(content)
btn_save.config (state = DISABLED)
def change_title(self):
c_title = str(ent_title.get())
c_file = db.cur_dir + "\\\\" + dir_folder + "\\\\" + c_title + db.file_type
target = open(c_file, \'w+\', -1)
content = txt_main.get(1.0,END)
target.write(content)
os.remove(db.current_file)
lst_list.delete(0, END)
cur_dir = db.cur_dir
lst_entries = os.listdir(cur_dir + chr(92) + db.dir_folder + chr(92))
lst_filtered_entries = []
for every_entry in lst_entries:
if every_entry[len(every_entry)-len(db.file_type):] == db.file_type:
lst_filtered_entries.append(every_entry)
sorted(lst_filtered_entries)
cur_ind = 0
for every_entry in lst_filtered_entries:
lst_list.insert(END, str(every_entry[:-len(db.file_type)]))
if every_entry[:-len(db.file_type)] == c_title:
lst_list.select_set(cur_ind)
cur_ind += 1
db.current_file = db.cur_dir + "\\\\" + dir_folder + "\\\\" + c_title + db.file_type
db.cur_title = c_title
btn_change_title.config (state = DISABLED)
def new_file(self):
c_randtitle = "[" + str(random.randint(0,65535)) + "] New Concoction"
c_file = db.cur_dir + "\\\\" + dir_folder + "\\\\" + c_randtitle + db.file_type
#print("File: " + str(c_randtitle))
#print("Dir: " + str(c_file))
c_new = open(c_file, \'w+\', -1)
lst_list.delete(0, END)
venom.get_files(db.dir_folder)
lst_list.select_set(0)
def del_file(self):
venom.clean_area()
os.remove(db.current_file)
lst_list.delete(0, END)
lst_list.select_set(0)
cur_dir = db.cur_dir
lst_entries = os.listdir(cur_dir + chr(92) + db.dir_folder + chr(92))
lst_filtered_entries = []
for every_entry in lst_entries:
if every_entry[len(every_entry)-len(db.file_type):] == db.file_type:
lst_filtered_entries.append(every_entry)
sorted(lst_filtered_entries)
cur_ind = 0
for every_entry in lst_filtered_entries:
lst_list.insert(END, str(every_entry[:-len(db.file_type)]))
cur_ind += 1
lst_list.select_set(cur_ind-1)
venom.select_file(True)
btn_save.config (state = DISABLED)
btn_del.config (state = DISABLED)
def cl(self, target):
from tkinter import _tkinter
try:
target.config( bg = db.bg, fg = db.fg, \\
font= "Courier")
except _tkinter.TclError:
target.config( bg = db.bg )
try:
target.config(selectbackground = db.fg)
except _tkinter.TclError:
target.config( bg = db.bg )
def select_all(seelf,event):
txt_main.tag_add(SEL, "1.0", END)
txt_main.mark_set(INSERT, "1.0")
txt_main.see(INSERT)
return \'break\'
def comment_search(a,b): # Searched for CommentLines
lst_src = ["[r]","[g]","[b]","[p]","[y]", "[v]"]
txt_main.tag_config("[r]", foreground = "#ee4444", font = ("Courier", 12, "bold"))
txt_main.tag_config("[g]", foreground = "#44ee44", font = ("Courier", 12, "bold"))
txt_main.tag_config("[b]", foreground = "#4444ee", font = ("Courier", 12, "bold"))
txt_main.tag_config("[p]", foreground = "#FF80C0", font = ("Courier", 12, "bold"))
txt_main.tag_config("[y]", foreground = "#eeee44", font = ("Courier", 12, "bold"))
txt_main.tag_config("[v]", foreground = "#D600FF", font = ("Courier", 12, "bold"))
from tkinter import _tkinter
for every_tag in lst_src:
try:
src_length = txt_main.get(1.0, END)
src_length = len(src_length)
src_iteration = 0
while src_iteration < src_length:
src_start = src_iteration / 10
src_position = txt_main.search(every_tag, src_start, stopindex = END)
src_end = src_position
str_closing = str(every_tag[:1] + "/" + every_tag[1:])
src_end_position = txt_main.search(str_closing, src_end, stopindex = END)
src_start = src_position
src_end = src_end_position
txt_main.tag_add(every_tag , src_start, src_end + "+4c")
src_iteration += 1
except _tkinter.TclError:
False
# Attributes ------------------------------------------
db = database() # Assigns the class database to db
venom = VENOM() # Assigns the class VENOM to venom
#venom.check() # Checks if Venom is working
min_width = 800 # wnd_main\'s minimum width in px
min_height = 600 # wnd_main\'s minimum height in px
dir_folder = db.dir_folder # Current dir folder
#------------------------------------------------------
# Main WIndow -----------------------------------------
wnd_main = Tk()
wnd_main.config(width = min_width, height = min_height)
wnd_main.minsize(min_width, min_height)
wnd_main.geometry(\'-0+0\')
wnd_main.wm_title("TCC Code Concoctions [Ver. 0.1 Build 3 (Alpha)]")
#------------------------------------------------------
# Frames ----------------------------------------------
frm_left = Frame(wnd_main)
frm_left.pack(side = LEFT, fill = Y , padx = 5, pady = 5)
frm_rightup = Frame(wnd_main)
frm_rightup.pack(fill = X)
frm_rightbottom = Frame(wnd_main)
frm_rightbottom.pack(fill = X, side = BOTTOM)
frm_right = Frame(wnd_main)
frm_right.pack(side = RIGHT, expand = True, fill = BOTH)
#-------------------------------------------------------
# =========================== LEFT PANEL ==============================
# Scroll Bar ----------------------------------------------------------
scr_list = Scrollbar (frm_left,orient = VERTICAL)
#scr_list.pack(side = RIGHT,fill = Y)
# Label List ----------------------------------------------------------
lbl_list = Label(frm_left, text = "CONCOCTIONS:")
lbl_list.pack(fill = X, side = TOP)
# File List -----------------------------------------------------------
lst_list = Listbox(frm_left, width = 20, yscrollcommand = scr_list.set\\
, selectmode = SINGLE, relief = "flat", \\
highlightthickness = 0)
lst_list.pack(expand= True, fill = BOTH, pady = 10)
# =====================================================================
# ========================== RIGHT PANEL ==============================
# Title Label ------------------------------------------------------TOP
lbl_title = Label(frm_rightup, text= "Title: ")
lbl_title.pack(side = LEFT)
# "Change" Button -----------------------------------------------------
btn_change_title = Button(frm_rightup, text = "Change", \\
command = venom.change_title)
btn_change_title.pack(side = RIGHT , padx = 2 , pady = 5)
# Scroll Bar -------------------------------------------------------MID
scr_main = Scrollbar (frm_right, orient = VERTICAL)
#scr_main.pack(side= RIGHT, fill = Y)
# Title ---------------------------------------------------------------
ent_title = Entry(frm_rightup)
ent_title.pack(side = LEFT, expand = True, fill = X)
# TextArea-------------------------------------------------------------
txt_main = Text(frm_right, yscrollcommand = scr_main.set, undo=True, \\
insertbackground= "#FF80C0")
txt_main.pack(expand = True, fill = BOTH)
# Button Save ------------------------------------------------------BOT
btn_save = Button(frm_rightbottom, text = "Save Concoction", \\
command = venom.save_file)
btn_save.pack(side = LEFT , pady = 5 , padx = 2)
txt_main.bind("<Control-Key-s>", venom.save_file_h)
txt_main.bind("<Control-Key-S>", venom.save_file_h)
# Button New ----------------------------------------------------------
btn_new = Button(frm_rightbottom, text = "Create New",\\
command = venom.new_file)
btn_new.pack(side = LEFT , pady = 5 , padx = 2)
# Button Delete -------------------------------------------------------
btn_del = Button(frm_rightbottom, text = "Delete Concoction",\\
command = venom.del_file)
btn_del.pack(side = RIGHT , pady = 5 , padx = 2)
# =====================================================================
# Colorizing-----------------------------------------------------------
venom.cl(wnd_main)
venom.cl(frm_left)
venom.cl(frm_right)
venom.cl(frm_rightup)
venom.cl(frm_rightbottom)
venom.cl(lbl_title)
venom.cl(lst_list)
venom.cl(btn_change_title)
venom.cl(txt_main)
venom.cl(btn_save)
venom.cl(btn_del)
venom.cl(btn_new)
venom.cl(ent_title)
venom.cl(lbl_list)
#----------------------------------------------------------------------
# Opening Message -----------------------------------------------------
inst = open(db.cur_dir + "\\\\inst.dll", \'r+\' , -1)
inst_cont = inst.read(-1)
txt_main.insert(1.0, inst_cont)
venom.comment_search(True)
btn_save.config (state = DISABLED)
btn_change_title.config (state = DISABLED)
btn_del.config (state = DISABLED)
#----------------------------------------------------------------------
txt_main.config(fg = "#c0c0c0", pady = 10, padx = 10)
lst_list.config(selectbackground = db.fg, font=("Courier", 10, "bold"))
wnd_main.state(\'zoomed\')
wnd_main.iconbitmap(\'icn.ico\')
lst_list.bind(\'<<ListboxSelect>>\', venom.select_file)
txt_main.bind("<Control-Key-a>", venom.select_all)
txt_main.bind("<Control-Key-A>", venom.select_all)
txt_main.bind("<Key-space>", venom.comment_search)
lst_list.bind("<Motion>", venom.comment_search)
venom.get_files(dir_folder)
txt_main.config (tabs = "1c")
scr_main.config (command = txt_main.yview)
scr_list.config (command = lst_list.yview) # connects scrollbar to list
""" CODE SLOT 001 """
wnd_main.mainloop() # Main window\'s mainloop
# Script End =================================================================================================
""" CODE 001 ----------------------------------------------
for each_line in range(1000):
lst_list.insert(END, "Example Item " + str(each_line))
--------------------------------------------------------"""
""" SCRIPT DETAILS ::::::::::::::::::::::::::::
Scrypt Type : Fortressed / Husked
Guiding System : Weak (Script)
Script Version : 0.1 Build 4
Changelog :
[Build 1] -Foundations Created
[Build 2] -Main Skin Pack Creation
-bug fixes
[Build 3] -added color to selected list and text (db.bg)
-added #Comment color support \'00ee00\'
-txt_main foreground changed to \'c0c0c0\'
-Added save_file_h (binding conflicts)
-Padding of txt_main changed to 5
[Build 4] -Removed # as a color code.
- Added new color codes:
[r] this is a red line [/r]
[g] this is a green line [/g]
[b] this si a blue line [/b]
[y] this is a yellow line [/y]
[p] this is a pink line [/p]
[v] this is a vilot line [/v]
Bugs :
+ When [] is removed formatting will not change.
::::::::::::::::::::::::::::::::::::::::::::"""