如何将tkinter文本传递给flex [英] how to pass tkinter text to flex

查看:99
本文介绍了如何将tkinter文本传递给flex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于c-bison-flex的项目.我已经开始为它构建一个python-tkinter环境,但是我陷入了陷阱. 我打算将tkinter编辑窗口的内容复制到"c"应用程序的缓冲区中.文本传递没有问题,我可以使用'c'函数-但是缓冲区地址未知.缓冲区是由flex动态"分配的. 有什么解决方法吗? (也许无动于衷,但系统是Ubuntu.)

I have a working c-bison-flex based project. I've started to build a python-tkinter environment for it, but I was fallen into a trap. I intended to copy the content of the tkinter's edit window to the buffer of 'c' application. There is no problem with text passing, I can reach the 'c' functions - but the buffer address is not known. The buffer is allocated by flex 'on the fly'. Any idea to workaround it? (Perhaps indifferent, but the system is Ubuntu.)

推荐答案

flex提供了一个用于在不同输入缓冲区之间进行切换的接口,包括使用功能yy_scan_string(有关详细信息,请参见 Flex手册 )

flex provides an interface for switching between different input buffers, including the possibility of specifying an in-memory input buffer with the functions yy_scan_string and yy_scan_bytes (See the Flex manual for details.)

正如手册所说,这些例程会复制字符串,因此您仍然不知道flex中字符串的地址.但这确实意味着您在创建flex缓冲区后不需要保留字符串,这在与脚本系统接口时很方便.

As the manual says, these routines make a copy of the string, so you still don't know the address of the string in flex. But it does mean that you don't need to keep the string around after you've created the flex buffer, which is convenient when you're interfacing with scripting systems.

这篇关于如何将tkinter文本传递给flex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆