razstec 31 Junior Poster in Training

hope this can help.

the absolute path is something, it didnt start like that but then i add a little function to backups the txt´s and they stop working. ill get to it latter, like you say its probable nothing.

thanks

run.png

ok.png

razstec 31 Junior Poster in Training

you can run it like this

import os
import time
from tkinter import *
import tkinter as tk
from tkinter import ttk, PhotoImage, LabelFrame, Text, GROOVE, Button, Label, scrolledtext
from tkinter.scrolledtext import ScrolledText
import requests
import json


global get_inp_cond_endpoint, get_inp_cond_id
tabmain1 = Tk()
w, h = tabmain1.winfo_screenwidth(), tabmain1.winfo_screenheight()
tabmain1.geometry("%dx%d+0+0" % (w, h))


frmmain = Label(tabmain1, text='')
frmmain.pack(side='top', fill='x', expand=False)
###########################################nova janela####################################

def gera_forms(get_inp_cond_id, get_inp_cond_endpoint):


    frmmain.pack_forget()




    nome_endpoint, timeoutvar, url_endpoint = get_inp_cond_endpoint.split('<:>')
    nome_endpoint = nome_endpoint.replace('  ', '').strip()
    url_endpoint = url_endpoint.replace(' ', '').strip()
    timeoutvar = timeoutvar.replace(' ', '').strip()


    photRun = PhotoImage(file=r'/Users/ricardosimoes/PycharmProjects/pythonProject/OCP/img/run.png')
    photoOK = PhotoImage(file=r'/Users/ricardosimoes/PycharmProjects/pythonProject/OCP/img/ok.png')
    photoNot = PhotoImage(file=r'/Users/ricardosimoes/PycharmProjects/pythonProject/OCP/img/notok.png')

    headers = {'Content-Type': 'application/json', 'chargingstation':'stat1'}

    tiporeq = ""
    payload = json.dumps({})
    expResp = ""

    varconfbook = open("/Users/ricardosimoes/PycharmProjects/pythonProject/OCP/Confs/json_dumps.txt", "r").readlines()
    lsttiporeq = []
    lsttitreq = []
    lstjsonreq = []
    lstexpectresq = []





    def makesubmenu(tipo_de_conf, framename):
        cont = 0
        rowcont=0

        frm_json_case_button = ttk.Frame(framename)
        frm_json_case_button.grid(column=0, row=0, rowspan=99)

        frm_txt_json_case = ttk.Frame(framename)
        frm_txt_json_case.grid(column=1, row=0)



        url_show=ttk.Label(frm_txt_json_case, text=nome_endpoint + "  @  " + str(url_endpoint + tipo_de_conf) + "  @  " + get_inp_cond_id)
        url_show.grid(column=1, row=0, columnspan=99, padx=10, pady=10)

        ttk.Label(frm_txt_json_case, text="Request:").grid(column=2, row=1, padx=10, pady=10)
        reqst_input = ScrolledText(frm_txt_json_case, width=75, height=10, wrap=tk.WORD)
        reqst_input.grid(column=2, row=2, padx=10, pady=10, ipady=35)

        ttk.Label(frm_txt_json_case, text="Expected Response:").grid(column=2, row=3, rowspan=1, padx=10, pady=10)
        lblexpect = ScrolledText(frm_txt_json_case, width=75, height=10, wrap=tk.WORD)
        lblexpect.grid(column=2, row=4, padx=10, pady=10, ipady=15)



        resp_json_input = ScrolledText(frm_txt_json_case, width=75, height=10, wrap=tk.WORD)
        resp_json_input.grid(column=4, row=2, padx=10, pady=10, ipady=35)

        ttk.Button(frm_txt_json_case, text="Run", image=photRun,command=lambda resp_json=resp_json_input, reqtxt=reqst_input, tiporeq=tipo_de_conf: runpost(resp_json, reqtxt, tiporeq)).grid(column=3, row=2, padx=10, pady=10, ipady=65)
        ttk.Label(frm_txt_json_case, text="Response:").grid(column=4, row=1, padx=10, pady=10)

        ttk.Label(frm_txt_json_case, text="Response / OBS:").grid(column=3, row=3, columnspan=5, padx=10, pady=10)
        resp_kiblog = ScrolledText(frm_txt_json_case, width=95, height=10)
        resp_kiblog.grid(column=3, row=4, padx=10, columnspan=5, rowspan=10, pady=10, ipady=120)

        frm_but_oknot = ttk.Frame(frm_txt_json_case)
        frm_but_oknot.grid(column=2, …
razstec 31 Junior Poster in Training

dont apologise, i apologise, your helping me thank you so much.

geraform us called by

 gera_forms(get_inp_cond_id, get_inp_cond_endpoint)

something like: gera_forms(stat1,nome_end<->30<->http://something.com)
get_inp_cond_endpoint=(nome_end<->30<->http://something.com)

razstec 31 Junior Poster in Training

i, thanks, im still testing it and its not ready yet, but if you like its this

from xlwt import XFStyle, Font, Workbook
import xlwt
import time

filename = "Reports/"+time.strftime("%Y%m%d-%H%M%S")+'_easlo1.xls'
wb = Workbook()
sheet1 = wb.add_sheet('Test')


global valColuna, valRow
valColuna = 0
valRow = 0

def savetoxls(jsonresponse):

    #  set the font
    style = xlwt.XFStyle()
    font = xlwt.Font()
    font.bold = True  # bold
    font.name = 'Times New Roman'  # select the font
    font.underline = False  # font underline
    font.italic = False  # italics
    font.height = 300  # the font size
    font.colour_index = 4  # the font color ::1-branco, 2-vermelho, 3-verde, 4-azul
    style.font = font

    style = xlwt.easyxf('pattern: pattern solid, fore_colour red')

    # VERT_TOP, VERT_CENTER, VERT_BOTTOM, VERT_JUSTIFIED, VERT_DISTRIBUTED
    aligment = xlwt.Alignment()
    aligment.horz = aligment.HORZ_JUSTIFIED  # horizontal alignment
    aligment.vert = aligment.VERT_JUSTIFIED  # perpendicular to its way
    style.alignment = aligment

    valColuna = +1
    valRow = +1

    sheet1.col(int(valColuna)).width = 13500  # MAX:65535
    sheet1.write(int(valRow), int(valColuna), str(jsonresponse), style)  # response
    wb.save(filename)

you can also just remove the import and jsonresponse=resp_json.get(1.0, "end-1c")

razstec 31 Junior Poster in Training
import time
from tkinter import *
import tkinter as tk
from tkinter import ttk, PhotoImage, LabelFrame, Text, GROOVE, Button, Label, scrolledtext
from tkinter.scrolledtext import ScrolledText
import requests
import json
from xpto.makeReport import savetoxls



###########################################nova janela####################################

def gera_forms(get_inp_cond_id, get_inp_cond_endpoint):
    from xpto.formularios import tabmain1, frmmain, btngera, getcondicion

    frmmain.pack_forget()
    btngera.pack_forget()
    getcondicion()


    nome_endpoint, timeoutvar, url_endpoint = get_inp_cond_endpoint.split('<:>')
    nome_endpoint = nome_endpoint.replace('  ', '').strip()
    url_endpoint = url_endpoint.replace(' ', '').strip()
    timeoutvar = timeoutvar.replace(' ', '').strip()


    photRun = PhotoImage(file=r'img/run.png')
    photoOK = PhotoImage(file=r'img/ok.png')
    photoNot = PhotoImage(file=r'img/notok.png')

    headers = {'Content-Type': 'application/json', 'chargeid':'TACW2242520G0479'}

    tiporeq = ""
    payload = json.dumps({})
    expResp = ""

    varconfbook = open("Confs/json_dumps.txt", "r").readlines()
    lsttiporeq = []
    lsttitreq = []
    lstjsonreq = []
    lstexpectresq = []





    def makesubmenu(tipo_de_conf, framename):
        cont = 0
        rowcont=0

        frm_json_case_button = ttk.Frame(framename)
        frm_json_case_button.grid(column=0, row=0, rowspan=99)

        frm_txt_json_case = ttk.Frame(framename)
        frm_txt_json_case.grid(column=1, row=0)



        url_show=ttk.Label(frm_txt_json_case, text=nome_endpoint + "  @  " + str(url_endpoint + tipo_de_conf) + "  @  " + get_inp_cond_id)
        url_show.grid(column=1, row=0, columnspan=99, padx=10, pady=10)

        ttk.Label(frm_txt_json_case, text="Request:").grid(column=2, row=1, padx=10, pady=10)
        reqst_input = ScrolledText(frm_txt_json_case, width=75, height=10, wrap=tk.WORD)
        reqst_input.grid(column=2, row=2, padx=10, pady=10, ipady=35)

        ttk.Label(frm_txt_json_case, text="Expected Response:").grid(column=2, row=3, rowspan=1, padx=10, pady=10)
        lblexpect = ScrolledText(frm_txt_json_case, width=75, height=10, wrap=tk.WORD)
        lblexpect.grid(column=2, row=4, padx=10, pady=10, ipady=15)



        resp_json_input = ScrolledText(frm_txt_json_case, width=75, height=10, wrap=tk.WORD)
        resp_json_input.grid(column=4, row=2, padx=10, pady=10, ipady=35)

        ttk.Button(frm_txt_json_case, text="Run", image=photRun,command=lambda resp_json=resp_json_input, reqtxt=reqst_input, tiporeq=tipo_de_conf: runpost(resp_json, reqtxt, tiporeq)).grid(column=3, row=2, padx=10, pady=10, ipady=65)
        ttk.Label(frm_txt_json_case, text="Response:").grid(column=4, row=1, padx=10, pady=10)

        ttk.Label(frm_txt_json_case, text="Response / OBS:").grid(column=3, row=3, columnspan=5, padx=10, pady=10)
        resp_kiblog = ScrolledText(frm_txt_json_case, width=95, height=10)
        resp_kiblog.grid(column=3, row=4, padx=10, columnspan=5, rowspan=10, pady=10, ipady=120)

        frm_but_oknot = ttk.Frame(frm_txt_json_case)
        frm_but_oknot.grid(column=2, row=5, padx=1, pady=1)

        ttk.Button(frm_but_oknot, width="15", text="OK", image=photoOK, command=lambda: savetoxls(jsonresponse)).grid(column=0, row=0,padx=1, pady=15)
        ttk.Button(frm_but_oknot, width="15", text="Not Ok", image=photoNot).grid(column=1, row=0, …
razstec 31 Junior Poster in Training

maybe

        for line in varconfbook:
    tabb, tiporeq, titreq, jsonreq, expectresq = line.split('<->')
    if "tab1" in tabb and tab1done:
        tab1 = ttk.Frame(tabControl)
        tabControl.add(tab1, text=tiporeq)
        tabControl.pack(expand=1, fill="both")
        tab1done=1

    if "tab2" in tabb and tab2done:
        tab2 = ttk.Frame(tabControl)
        tabControl.add(tab2, text=tiporeq)
        tabControl.pack(expand=1, fill="both")
        tab2done=1
razstec 31 Junior Poster in Training

maybe i should just do it like this

lsttiporeq1 = []
tabblers = []
for line in varconfbook:
    tabb, tiporeq, titreq, jsonreq, expectresq = line.split('<->')
    if tabb not in tabblers:
        tabblers.append(tabb)
    if tiporeq not in lsttiporeq1:
        lsttiporeq1.append(tiporeq)

if "tab1" in tabblers:
    # tab1
    tab1 = ttk.Frame(tabControl)
    tabControl.add(tab1, text=lsttiporeq1[x])

if "tab2" in tabblers:
# Tab2
    tab2 = ttk.Frame(tabControl)
    tabControl.add(tab2, text=lsttiporeq1[x])
    tabControl.pack(expand=1, fill="both")

and create 30tab in order to compensate for future updates

how do i get the correct x, im pretty sure im not doing this right :s

razstec 31 Junior Poster in Training

Thanks :)

the class worked but im having some dificulty populating it right

here how i have it

varconfbook = open("Confs/json_dumps.txt", "r").readlines()
class TextTabControl(ttk.Notebook):
    def __init__(self, rootWidget, parentWidget, tabData):
        super().__init__(rootWidget)
        self.__root__ = rootWidget
        self.__tabData__ = tabData
        # populate the tabs
        for key in self.__tabData__:
            tab = parentWidget(self)
            ttk.Label(tab, text=self.__tabData__[key]).grid(column=0, row=0, padx=10, pady=10)
            super().add(tab, text=key)
        # pack the final set of tab widgets
        self.pack(expand=1, fill=&quot;both&quot;)




lsttiporeq1 = []# list with tab1, tab2 tab3, etc....
tabblers = []#list with names of tab 
for line in varconfbook:
    tabb, title, xxx1, xxx2, xxx3 = line.split('&lt;-&gt;')
    if tabb not in tabblers:
        tabblers.append(tabb)
    if title not in lsttiporeq1:
        lsttiporeq1.append(title)

for x in lsttiporeq1:             
    textTabControl1 = TextTabControl(tabmain1,
                                 ttk.Frame,
                                 {x})
razstec 31 Junior Poster in Training

found this that might help you

# Python program to find the factorial of a number provided by the user.

# change the value for a different result
num = 7

# To take input from the user
#num = int(input("Enter a number: "))

factorial = 1

# check if the number is negative, positive or zero
if num < 0:
   print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
   print("The factorial of 0 is 1")
else:
   for i in range(1,num + 1):
       factorial = factorial*i
   print("The factorial of",num,"is",factorial)
razstec 31 Junior Poster in Training

Also, can i put my vars in a txt like this:

var1=something1
var2=something2

and access them from python?

razstec 31 Junior Poster in Training

Im new to python , trying to update my self from the time of ASP Classic.
In that time i use to have a page for vars that i included in my main page.

I like that method because i can keep all my vars organized.

I tried to do that with python but allways get errors, yes i tried declare them as global as well but still got errors.

Is there a way to do that with python or is it better to declare them as you go?

thanks

razstec 31 Junior Poster in Training

Schol-R-LEA, that wont work, all the tabs will be tab and not tab1, tab2, tab3....

and even when i tried i get

frmbtnspecs = ttk.Frame(Tab1)
frmbtnspecs.pack(side=TOP)

NameError: name 'tab1' is not defined

razstec 31 Junior Poster in Training

this already bellongs to a notebbok

tabControl = ttk.Notebook(tabmain1)

im trying to do this also in order of not having 10 or more like this

 #tab1
  Tab1 = ttk.Frame(tabControl)
    tabControl.add(Tab1, text='Initialized messages')

    # Tab2
    tab2 = ttk.Frame(tabControl)
    tabControl.add(tab2, text='Change Configuration')
    tabControl.pack(expand=1, fill="both")

    # Tab3
    tab3 = ttk.Frame(tabControl)
    tabControl.add(tab3, text='Clear Cache')
    tabControl.pack(expand=1, fill="both")

    .....

    tab10
    ......
razstec 31 Junior Poster in Training

I would like through a list or dict populated by a text to create a frames, this way I could update an app without having to mess with the code, can someone help me?

Seria algo assim:

vars.txt:

tab1 <-> nome1
tab2 <-> nome2
tab3 <-> nome3
tab4 <-> nome4

tab5 <-> nome5

varlist = open("Confs/vars.txt", "r").readlines()
for line in varlist:
     tab, nome = line.split('<->')   
     tab = ttk.Frame(tabControl)
     tabControl.add(tab, text=nome)
     tabControl.pack(expand=1, fill="both")

 makesubmenu(nome,tab)

can this be done?
thanks

razstec 31 Junior Poster in Training

but i need a files viewer without save or print that is portable and allow me to call it with a batch file

razstec 31 Junior Poster in Training

Any idea of a script that convert excel to asp? thanks

razstec 31 Junior Poster in Training

Hi everyone,

I haven't touch in vb6 in 12 years so im very rusty... :s

But now i need a little exe that allow to open and view office and pdf files, i dont need it to save or allow changes.

Since its going to work with a batch file it doesnt even need a file explorer, just the window with the ability to drag file to window and it opens the file.

Can anyone give me some help?

thanks

razstec 31 Junior Poster in Training

Hi, thanks i see some potencial althought i only need to get the text.

Im builder a store bot to get products for resellers. i only need the text.

thanks
obrigado

razstec 31 Junior Poster in Training

i program in asp but i can use php also, could you give a more complete example?
thanks

razstec 31 Junior Poster in Training

Hi all, can someone help me get the content of a div in a web site in another domain?
Im a little lost with this.
thanks