tcl

tcl string replacement

半腔热情 提交于 2020-01-01 16:09:42
问题 $arg=TEST #### Requested, NOT AVAILABLE psy #; I have a string above where the # is dynamically generated. I have to use a function in tcl to do a string replacement. Basically I need to remove the comma(,) form the above expression and display it as TEST #### Requested NOT AVAILABLE psy # Here's what I did, but it is not working. regsub -all {"Requested,"} $arg {"Requested"} arg This is where i referenced the function from: http://www.tcl.tk/man/tcl8.5/TclCmd/regsub.htm 回答1: The problem is

tcl string replacement

淺唱寂寞╮ 提交于 2020-01-01 16:07:14
问题 $arg=TEST #### Requested, NOT AVAILABLE psy #; I have a string above where the # is dynamically generated. I have to use a function in tcl to do a string replacement. Basically I need to remove the comma(,) form the above expression and display it as TEST #### Requested NOT AVAILABLE psy # Here's what I did, but it is not working. regsub -all {"Requested,"} $arg {"Requested"} arg This is where i referenced the function from: http://www.tcl.tk/man/tcl8.5/TclCmd/regsub.htm 回答1: The problem is

Using Python functions in Tkinter.Tcl()

瘦欲@ 提交于 2020-01-01 06:47:14
问题 I have a bunch of Python functions. Let's call them foo , bar and baz . They accept variable number of string arguments and does other sophisticated things (like accessing the network). I want the "user" (let's assume he is only familiar with Tcl) to write scripts in Tcl using those functions. Here's an example (taken from Macports) that user can come up with: post-configure { if {[variant_isset universal]} { set conflags "" foreach arch ${configure.universal_archs} { if {${arch} == "i386"}

Using Python functions in Tkinter.Tcl()

落花浮王杯 提交于 2020-01-01 06:46:06
问题 I have a bunch of Python functions. Let's call them foo , bar and baz . They accept variable number of string arguments and does other sophisticated things (like accessing the network). I want the "user" (let's assume he is only familiar with Tcl) to write scripts in Tcl using those functions. Here's an example (taken from Macports) that user can come up with: post-configure { if {[variant_isset universal]} { set conflags "" foreach arch ${configure.universal_archs} { if {${arch} == "i386"}

General string quoting for TCL

谁说我不能喝 提交于 2019-12-31 19:37:20
问题 I'm writing a utility (which happens to be in python) which is generating output in the form of a TCL script. Given some arbitrary string variable (not unicode) in the python, I want to produce a TCL line like set s something ... which will set TCL variable ' s ' to that exact string, regardless of what strange characters are in it. Without getting too weird, I don't want to make the output messier than needed. I believe a decent approach is if the string is not empty and contains only

Returning arrays from Procedures in TCL

爱⌒轻易说出口 提交于 2019-12-31 02:54:09
问题 I want to pass array and return array from a procedure, the following is the sample code i tried. But getting some errors.. set a(0) "11" set a(1) "10" set a(2) "20" set a(3) "30" set a(4) "40" proc deleten somet { upvar $somet myarr for { set i 1} { $i < [array size myarr]} { incr i} { set arr($i) $myarr($i) } return arr } array set some[array get [deleten a]] parray some when i run this code i get the following error wrong # args: should be "array set arrayName list". I'm pretty sure that i

Tcl adds curly braces when using `$` sign

旧城冷巷雨未停 提交于 2019-12-31 02:52:27
问题 set B {pc_0::!mx_0 pi::$mx_0} puts $B set A "" foreach x $B { lappend A $x } puts $A The output of this program is pc_0::!mx_0 pi::$mx_0 pc_0::!mx_0 {pi::$mx_0} It is strange that tcl adds curly braces in second output. I guess it is because it uses $ symbol. But I really need to use it and I don't want the braces to be inserted. How this can be explained and how to avoid the braces? 回答1: As a general rule, don't treat lists as strings . Pretend that they don't have a string representation.

Pass Python variables to `Tkinter.Tcl().eval()`

一个人想着一个人 提交于 2019-12-31 02:36:28
问题 I can source a Tcl script, and run a proc from said script like so: import Tkinter >>> tclsh = Tkinter.Tcl() >>> tclsh.eval('source {myscript.tcl}') >>> tclsh.eval('myproc') ...[output of proc] >>> However, should I want to pass variables to this proc, I have to do it like so (assuming the proc takes a dict as a parameter: >>> tclsh.eval('dict set spec num 10000') >>> tclsh.eval('dict set spec time 10000') >>> tclsh.eval('dict set spec rate 10') Is there an easier, more-Pythonic way to do

How to make Tkinter columns of equal width when widgets span multiple columns (Python 2.7)

旧街凉风 提交于 2019-12-31 01:54:08
问题 In the following, the buttons labelled 'ONE', 'TWO', and 'THR' do not get evenly spaced out. It seems to me that the root of the problem is that Tk is assuming a default minimum width for any column containing part of a widget that spans multiple columns. However, this behaviour appears to be undocumented, so I am unsure how to accommodate for or adjust it in order to get the columns to be of equal width - including the two columns spanned by the text widget and the single column not spanned

How to automate console scenario using TCL script? [closed]

浪尽此生 提交于 2019-12-30 11:32:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I want to automate the following scenario: Login into a router Give reload When reloading a router, press ESP key continuously. When pressing a ESP key , boot> prompt will come. execute some commands in this. I can do the above things manually, using "Teraterm" and console. But